fixed tabsContext
This commit is contained in:
parent
90974d9ef4
commit
d05483d735
1 changed files with 9 additions and 8 deletions
|
|
@ -23,18 +23,19 @@ export const TabsContext = createContext<TabsContextType>(TabsContextInitialValu
|
||||||
|
|
||||||
export function TabsProvider({children}){
|
export function TabsProvider({children}){
|
||||||
const [tabIndex,setTabIndex] = useState(0)
|
const [tabIndex,setTabIndex] = useState(0)
|
||||||
const [flows,setFlows] = useState<Array<flow>>(JSON.parse(window.sessionStorage.getItem('tabs'))??[])
|
const [flows,setFlows] = useState<Array<flow>>([])
|
||||||
function removeFlow(index:number){
|
function removeFlow(index:number){
|
||||||
let newFlows = flows
|
let newFlows = flows
|
||||||
newFlows.splice(index)
|
newFlows.splice(index,1)
|
||||||
window.sessionStorage.setItem('tabs',JSON.stringify(newFlows))
|
window.sessionStorage.setItem('tabs',JSON.stringify(newFlows))
|
||||||
setFlows(newFlows)
|
setFlows(newFlows)
|
||||||
}
|
}
|
||||||
function addFlow(newFlow: flow) {
|
function addFlow(newFlow: flow) {
|
||||||
let newFlows = [...flows,newFlow]
|
setFlows(prevState => {
|
||||||
window.sessionStorage.setItem('tabs',JSON.stringify(newFlows))
|
const newFlows = [...prevState, newFlow];
|
||||||
setFlows(newFlows)
|
window.sessionStorage.setItem('tabs', JSON.stringify(newFlows));
|
||||||
|
return newFlows;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return(
|
return(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue