title: How to fix error ,Uncaught TypeError: Cannot read properties of null (reading 'id')
body: <p>I'm getting the following error: Uncaught TypeError: Cannot read properties of null (reading 'id').
  <strong>but when i change my initialState (object ) then it works fine</strong></p>
  <pre><code>type AnchorElAction = {
    id: string;
    domTarget: React.ReactNode;
  } | null;
  
  const [anchorEl, setAnchorEl] = useState&lt;AnchorElAction | null&gt;(null);
  
  
  return (
         {events?.map((event, index) =&gt; {
            return (
              &lt;Styled.Event key={`${event.id}:${event.name}`} onClick={handleOpenPopover(event.id)}&gt;
                {renderShifts(event)}
                {anchorEl.id === event.id &amp;&amp; (
                  &lt;ShiftPopover
                    start={event.start}
                    end={event.end}
                    name={event.name}
                    id={event.id}
                    onClose={handleCloseModal}
                    anchorEl={anchorEl.domTarget}
                    open={Boolean(anchorEl.domTarget)}
                  /&gt;
                )}
              &lt;/Styled.Event&gt;
            );
          })}
  )
  </code></pre>