Relative Content

Tag Archive for javascriptreactjsroutesreact-router

Too many re-renders. React limits the number of renders to prevent an infinite loop in React

import React from ‘react’ import { useState } from ‘react’ export default function About(props) { const [theme,setTheme] = useState(null) function toggle(option){ if(option===”light”){ setTheme({ color:”black”, backgroundColor:”white”, width:”90%”, marginInline:”auto” }) console.log(theme,option===”light”); // return theme }else if(option===”dark”){ setTheme({ color:”white”, backgroundColor:”black”, width:”90%”, marginInline:”auto” }) console.log(theme,option===”light”); // return theme }else{ setTheme({ color:”white”, backgroundColor:”#032f3c”, width:”90%”, marginInline:”auto” }) console.log(theme,option===”light”); // return theme […]