The below block of code works. Component rerenders when state changes from parent (MainBox)
export function MainBox(){ const [valuestate, setvalueState] = useState() return( <div> <Component value={valuestate}/> </div> ) } However I initially want to have a skeleton animation div, and make an api call to fetch some data. Once the data arrives I then render the Component. However when the state changes the Component does not rerender. On top of that, the value prop is always undefined
export function MainBox(){ const [valuestate, setvalueState] = useState() const [divstate, setdivState] = useState(<div className='skeleton'/>) useEffect(() =>{ GetUserInfo() },[]) async function GetUserInfo(){ let response = await fetch('some url', { method: 'GET', }).then(res => {return res.json() }).then(data => data) setvalueState(response) setdivState(<Component value={valuestate}/>) } return( {divstate} ) } The problem is that: Although Component does render the value withing in always undefined (regardless of how many times i change the valuestate from parent (MainBox)). Am I doing something wrong? Is there a different way to go about this?
.then(data => data)🤨