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