DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 967,611 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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)

πŸ‘‹ Hey, my name is Noah and I’m the one who set up this ad. My job is to get you to join DEV, so if you fancy doing me a favor, I’d love for you to create an account.

If you found DEV from searching around, here are a couple of our most popular articles on DEV: