I want to show / hide a P tag in the footer based on the url it is in.
I did it in development mode and it worked:
{acf2.texto_2_rodape_coluna_2.length > 0 && window.location.href.indexOf("mydomain")? (
<>
<p className="contact">
<HiCursorClick/> <Link to={acf2.link_call_1} style={{ fontWeight: '600' }}>
{acf2.texto_2_rodape_coluna_2}
</Link>
</p>
</>
) : null}
{acf2.texto_3_rodape_coluna_2.length > 0 && !window.location.href.indexOf("mydomain/")? (
<p className="contact">
<AiTwotoneVideoCamera/> <Link to={acf2.link_to_action_2} style={{ fontWeight: '600' }}>
{acf2.texto_3_rodape_coluna_2}
</Link>
</p>
) : null}
In development mode it works, but when I send to netlify this error occurs:
error: "window" is not available during server side rendering.
WebpackError: ReferenceError: window is not defined