I'm trying to use the react useEffect hooks to check if the cookies is accepted on the first render. But when I test it by logging out and logging in again or closing and reopening the browser, it doesn't behave the way it should. By behavior I mean each time the user logs in, it should render the cookie banner. What am I missing?
This is the relevant code.
 const firstRender = useRef(true);
  React.useEffect(() => {
  firstRender.current === false;
    return () => {
      if (firstRender.current === true) {
        cookiesAccepted === 'true';
      }
    };
  }, [handleAcceptCookies]);
