Updating an ID tag on scroll React.js

You can find my project here: https://codesandbox.io/s/franchise-bg-effect-obd55

I am trying to match an array of CSS background ID tags (bgArr) to an array of each section (destination.index) in afterLoad(). So section 1 should have the ID of ‘red’, section 2 ID of ‘blue’, and section 3 ID of ‘green’. On page load, section 1 has the correct ID tag of ‘red’. When scrolling to section 2, in the console you will notice that bgIndex updates to the correct ID tag of ‘blue’ but the ID of the div on the page remains red. I’m not sure how to re-render the div with the updated ID tag.

96 thoughts on “Updating an ID tag on scroll React.js”

  1. Your writing style is cool and I have learned several just right stuff here. I can see how much effort you’ve poured in to come up with such informative posts about Blogging. If you need more input, feel free to check out my website at xrank.cyou

    Reply

Leave a Comment