DEV Community

Cover image for ReactJS Suppressing the footer element when user navigates to a page
SunbeamRapier
SunbeamRapier

Posted on

ReactJS Suppressing the footer element when user navigates to a page

I want to suppress the footer permanently when a user navigates to a specific page for my new book (the footer encourages the user to visit this page and would be annoying if on permanently).

I thought it would be relatively easy to count the actual page views (ignoring the startup execution of the code.)

The view count uses state:

const [DisplayCount, setDisplayCount] = useState(0);

But I can't update the value in DisplayCount when the user navigates to the page whatever I try.

There are no buttons involved and a regular function called by the main function will update the value and attempts to return it, but the main function ignores the returned values.

from Chrome DevTools...
Function - DisplayCount after increment = [1]
Function - Returning [1]

MAIN - Function returned DisplayCount = [0]

It is such a simple thing, but I have spent 2 days on this now and have not got anywhere...

Any suggestions greatly appreciated !

Rapier

Top comments (0)