Skip to content
Discussion options

You must be logged in to vote

When the item is removed, that native object can be released while the component is still mounted

How is this native object released? If you release it manually while chaning state (items in the context) you can simply move this native state cleanup to the useEffect used within this component. In general, cleaning up the native state right away in the callback, independent from the component that depends on this state, doesn't seem to be a valid and safe approach.

I'd suggest doing something like this if possible:

function GridItem() {
  useEffect(() => {
    return () => {
      // perform cleanup here
    };
  }, []);
}

I'm curious to see whether synchronous store changes would work.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@MatiPl01
Comment options

@MatiPl01
Comment options

@JustJoostNL
Comment options

@MatiPl01
Comment options

Answer selected by JustJoostNL
@JustJoostNL
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants