How to solve problem with too many re-renders in context ? I have the same context in other project and it works. I dont know what is wrong with it. Even if I comment out everything in provider when I use setState it is crash. Without using it works. I have wrapped App component with Provider. Even when I
m wrapping single Component it crash.
CONTEXT
export const DataContext = createContext({
list:null,
dragCheck:null,
setList:()=>{},
setDragCheck:()=>{}
})
export const DataProvider = ({children}) => {
let data = Data
const [list,setList] = useState(null);
const [dragCheck,setDragCheck] = useState(null);
let path = window.location.pathname
switch(path){
case '/code':
setList(data.code.list.questions)
setDragCheck(data.code.drag_check)
break;
default:
console.log("bad");
break
}
return(
<DataContext.Provider value={{
list,
dragCheck,
setList,
setDragCheck
}}>
{children}
</DataContext.Provider>
)
}