Skip to content

Refresh the component on every tab change #1175

Open

Description

@yogendrajs

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)

Activity

  1. devoren commented on Jul 5, 2022

    @devoren

    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);
    }}
    ...`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions