react-native-scrollable-tab-view icon indicating copy to clipboard operation
react-native-scrollable-tab-view copied to clipboard

Refresh the component on every tab change

Open yogendrajs opened this issue 2 years ago • 1 comments

I want to know if there's a way to refresh the component on every tab change because componentDidMount doesn't re-invoke when we return to the rendered/previous tab (as it's already in the stack)

yogendrajs avatar May 30 '22 06:05 yogendrajs

Try something like this:

`const [tabIndex, setTabIndex] = useState(0); const [isRefreshing, setIsRefreshing] = useState(false);

React.useEffect(() => { setIsRefreshing(true) after fetching data setIsRefreshing(false) }, [tabIndex]);

<ScrollableTabView ... onChangeTab={(value) => { setTabIndex(value.i); }} ...</ScrollableTabView>`

devoren avatar Jul 05 '22 11:07 devoren