1

On every page, I do this function:

import * as sync_helper from '../utils/sync';

componentWillUnmount() { this._isMounted = false; }
componentDidMount() {

  this._isMounted = true;

  sync_helper.getLocal().then((l) => {

    if(this._isMounted)
      this.setState({ current_user: l.current_user,loaded: true });

  });
}

I also sometimes have a lot more async functions in the componentDidMount() but this one is in EVERY page.

Is there a way to automatically add my current_user to every state without putting this on every page?

I'm using React Navigation (Stacks)

bryan
  • 8,879
  • 18
  • 83
  • 166

0 Answers0