I have a banner that has it's visibility determined by the state of true or false. I have a close button with a clickHandler to set state to false, which hides the banner. When I navigate to a different page, the state resets to true, therefore the banner is visible.
How do I force the state to remain false, even if page refreshes or changes? Basically, I want the banner to not appear again, if the user closes it.
Note: Banner component is used a Layout component, which is used by all pages.
const BannerWrapper = styled.div`
visibility: ${props => (props.show ? "visible" : "hidden")};
`
const CloseIcon = styled.div`
position: absolute;
cursor: pointer;
`
const Banner = () => {
const [show, setShow] = useState(true)
const handleClick = () => {
setShow(false)
}
return (
<BannerWrapper show={show}>
Some Banner Content
<CloseIcon onClick={handleClick}>
X
</CloseIcon>
</BannerWrapper>
)
}
export default Banner