yasin demir
yasin demir

Reputation: 135

react native navigation screen won't ReRender

when go from category to productList for the first time everything is right but after i came back and try to go for second time list screen won't rerender or refresh what ever you call. is there anyone has suggestions

enter image description here

Upvotes: 0

Views: 883

Answers (2)

Ade Crown
Ade Crown

Reputation: 1280

The list Screen gets data on mount and that's it. If you want it to gets a new data every time the category name changes you have to add it to the useEffect dependencies like so.

  const categoryName = navigation.route.params.categoryName;
  useEffect(() => {
    getData();
  },[categoryName]);

Now every time categoryName changes getData gets called.

Upvotes: 2

Jensen
Jensen

Reputation: 6646

if you are using tabs just add unmountOnBlur: true, in the <Tab.Screen/> of the screen you are in

Upvotes: 0

Related Questions