question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Side effects like changing state are not allowed at this point

See original GitHub issue

I am quite new to Mobx so I suspect this problem might not be be Firestorter specific, but I’m hoping you have clue anyway.

I have a list of document ids what I use to fetch single document data one by one. I have a store which contains a Document, of which I change the path property via a “Next” button click handler which calls an @action.bound handler on the store and sets the next id.

I initially create the document without any path, with new Document().

When the next button triggers the action and the document path is set, I wait for document.fetching to be false and pass it down to a component for rendering.

When I hit the button and the path is set, I get this from my rendering component:

Side effects like changing state are not allowed at this point. Are you trying to modify state from, for example, the render function of a React component? Tried to modify: ObservableValue@16

The problem seems to stem from the fact that I’m passing down the observable Document as-is.

 <RegistrationShortView document={store.userRegistration} />

If I instead do this (map it to my own non-observable typed document structure), all is ok:

 <RegistrationShortView
    document={{
      id: store.userRegistration.id,
      data: store.userRegistration.data as UserRegistration
    }}
 />

The component does nothing more then de-structure some of the data props and renders them.

What might be causing this issue you think?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
steeltomatocommented, Jun 12, 2018

I can’t reproduce this anymore on v0.12.1

1reaction
IjzerenHeincommented, Jun 11, 2018

Hi, this should be fixed by using the new isLoading property instead of fetching in firestorter v0.12.1. Let me know if you still run into this problem with in case isLoading doesn’t solve it. cheers

Read more comments on GitHub >

github_iconTop Results From Across the Web

MobX Invariant failed: Side effects like changing state are not ...
I see you're changing the mobx-state without the wrapped code being in an action function. If a function changes the state, then it...
Read more >
Invariant failed: Side effects like changing state are not ...
Hi I am getting this error Uncaught Error: [mobx] Invariant failed: Side effects like changing state are not allowed at this point.
Read more >
Derive computed values and manage side effects with MobX ...
And reactions can be used to manage side effects, such as drawing the user ... computed values are not allowed to clear side...
Read more >
Running side effects with reactions - MobX
Unlike autorun , the side effect won't run once when initialized, but only after the data expression returns a new value for the...
Read more >
Side-effects in Compose - Android Developers
A side-effect is a change to the state of the app that happens outside the scope of a composable function. Due to composables'...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found