nodeId bug solved
This commit is contained in:
parent
9a12d6e43a
commit
7e300d62e2
2 changed files with 7 additions and 9 deletions
|
|
@ -9,7 +9,6 @@ type TabsContextType={
|
|||
removeFlow:(id:string)=>void;
|
||||
addFlow:()=>void;
|
||||
updateFlow:(newFlow:flow)=>void;
|
||||
setNodeId:(newState:any)=>void;
|
||||
nodeId:number;
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +19,6 @@ const TabsContextInitialValue = {
|
|||
removeFlow:(id:string)=>{},
|
||||
addFlow:()=>{},
|
||||
updateFlow:(newFlow:flow)=>{},
|
||||
setNodeId:(newState:any)=>{},
|
||||
nodeId:0,
|
||||
|
||||
|
||||
|
|
@ -32,7 +30,7 @@ export function TabsProvider({children}){
|
|||
const [tabIndex,setTabIndex] = useState(0)
|
||||
const [flows,setFlows] = useState<Array<flow>>([])
|
||||
const [id, setId] = useState(0);
|
||||
const [nodeId, setNodeId] = useState(0);
|
||||
let nodeId = 0;
|
||||
useEffect(() => {
|
||||
if(flows.length !== 0)
|
||||
window.localStorage.setItem('tabsData', JSON.stringify({tabIndex, flows, id, nodeId}));
|
||||
|
|
@ -45,7 +43,7 @@ export function TabsProvider({children}){
|
|||
setTabIndex(cookieObject.tabIndex);
|
||||
setFlows(cookieObject.flows)
|
||||
setId(cookieObject.id)
|
||||
setNodeId(cookieObject.nodeId)
|
||||
nodeId = cookieObject.nodeId
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
|
@ -89,7 +87,7 @@ export function TabsProvider({children}){
|
|||
}
|
||||
|
||||
return(
|
||||
<TabsContext.Provider value={{tabIndex,setTabIndex,flows,setNodeId, nodeId,removeFlow,addFlow,updateFlow}}>
|
||||
<TabsContext.Provider value={{tabIndex,setTabIndex,flows, nodeId,removeFlow,addFlow,updateFlow}}>
|
||||
{children}
|
||||
</TabsContext.Provider>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -32,15 +32,15 @@ const nodeTypes = {
|
|||
var _ = require("lodash");
|
||||
|
||||
export default function FlowPage({ flow }) {
|
||||
const { updateFlow, nodeId, setNodeId } = useContext(TabsContext);
|
||||
let { updateFlow, nodeId } = useContext(TabsContext);
|
||||
const { types, reactFlowInstance, setReactFlowInstance } =
|
||||
useContext(typesContext);
|
||||
const reactFlowWrapper = useRef(null);
|
||||
|
||||
const getId = () => {
|
||||
function getId(){
|
||||
console.log(nodeId);
|
||||
setNodeId(old => old + 1);
|
||||
return `dndnode_${nodeId}`;
|
||||
nodeId = nodeId+1
|
||||
return `dndnode_}`+nodeId;
|
||||
};
|
||||
|
||||
const { setExtraComponent, setExtraNavigation } = useContext(locationContext);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue