- A component called "BasicSearch" is used on all pages.
- The search component should be displayed on full screen with a vertical scroll to see the contents with a close button on the right top corner.
- The search components have some default links to navigate to different pages.
React.useEffect(() => { document.body.style.position = "fixed"; }, []);
return (
<div className="container">
<Button onClick={() => { document.body.style.position = "relative"; }}> close </Button>
<a href="./xyz">Link1 </a>
<a href="./xyz-abc">Link2 </a>
</div>
);
The body element is set to position: relative when the close button is clicked. but, when the user navigates via any of the Link buttons then the body element is unchanged.
Could someone help me understand where I'm going wrong and how to fix this issue?