mobx-react icon indicating copy to clipboard operation
mobx-react copied to clipboard

Execute function on prop change.

Open jwhscholten opened this issue 9 years ago • 2 comments

Not sure if this is the way how mobx works in conjunction with React Native but I'm trying to do the following.

My header has a 'edit' button. This toggles the 'isEditing' state in my mobx store (true/false). I'm passing this throug via the 'edit' prop on my EventGrid component.


  render() {
    return (
          <EventGrid data={this.state.eventData} edit={this.props.EditMode} navigation={this.props.navigation}/>
    );
  }

Now, in my EventGrid component I'm trying to call a function to enable 'editing' mode whenever my mobx state value changes to true. Can anyone point me in the right direction?

jwhscholten avatar Jul 01 '17 12:07 jwhscholten

First, make sure you are using mobx react observer. Second, try creating a small test case. I know you're using react native, but you may be able to reproduce your issue with react dom.

On Sat, Jul 1, 2017, 7:58 AM jwhscholten [email protected] wrote:

Not sure if this is the way how mobx works in conjunction with React Native but I'm trying to do the following.

My header has a 'edit' button. This toggles the 'isEditing' state in my mobx store (true/false). I'm passing this throug via the 'edit' prop on my EventGrid component.

render() { return ( ); }

Now, in my EventGrid component I'm trying to call a function to enable 'editing' mode whenever my mobx state value changes to true. Can anyone point me in the right direction?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mobxjs/mobx-react/issues/291, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIrcoWEPJjLSVAUSNjXEvkgCG-6mWPOks5sJkJ3gaJpZM4OLTvi .

mattruby avatar Jul 01 '17 13:07 mattruby

Closing issue for inactivity / lack of context. Feel free to reopen if the answer is not sufficient and more details have been provided.

mweststrate avatar Jul 11 '17 12:07 mweststrate