I am passing an access token into a functional component as props. I need the functional component to re-render when the access token has change. I am using useEffect to setState when said access token has change. It is not re-rendering as expected.
const Panel = (props) => {
const [accessToken, setAccessToken] = useState('');
useEffect(() => {
setAccessToken(props.accessToken)
}, [props.accessToken])
return (...)
}
Expected: Panel re-render after props.accessToken changes.
Actual: Panel does not re-render with updated props.accessToken value.
accessTokenis passed toPanel? ie, a value that is not''as per the inital state?console.log("props.accessToken=", props.accessToken)before the line withuseState, what is logged?