Jump to content
Search Community

old state isn't saved in ScrollTrigger React

jacob.liu test
Moderator Tag

Recommended Posts

const setStoryContent = (sectionId=> {
    console.log("old description:"description"------------------------new description: "data.story[sectionId].description);
    setDescription(data.story[sectionId].description);
  };
 
//create scroll triggers for text panels
      ScrollTrigger.create({
        trigger: container,
        start: descStPx[idx=== 0 ? "top top" : descStPx[idx],
        end: "+=" + steps.length * PXS_PER_STEP,
        onEnter: () => setStoryContent(idx),
      });
 
 
ideally, console should be
"A", "B"
"B", "C"
"C", "D"
 
but current console log shows
"A", "B"
"A", "C"
"A", "D"
 
old description doesn't update,,, what's the issue?
 
 
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...