-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Side effects like changing state are not allowed at this point #18
Comments
Hi Thijs, I've only recently encountered this myself. The problem lies in the |
🙌 🎉 I was getting pretty desperate trying out all different things for about a day 😅 I solved it by forcing mode = "on" on all documents: public user = new FsDocument<User>(undefined, { mode: "on" });
public userRegistration = new FsDocument<UserRegistration>(undefined, {
mode: "on"
});
public userCredits = new FsDocument<UserCredits>(undefined, { mode: "on" });
public userMetrics = new FsDocument<UserMetrics>(undefined, { mode: "on" }); PS: I called your Document type FsDocument because I already had a Document of my own. |
Thijs, could you show how you are using the |
I am passing the observable documents into my view components and show a loading indicator. Something like below. type QuickAcceptViewProps = {
user: Document<User>;
userRegistration: Document<UserRegistration>;
};
@observer
export default class QuickAcceptView extends React.Component<
QuickAcceptViewProps
> {
public render() {
const { user, userRegistration } = this.props;
if (user.fetching || userRegistration.fetching) {
return <LoadingIndicator />;
}
const { data: userData, id: userId } = user;
const { data: userRegistrationData } = userRegistration;
// ... render actual data |
Ah I see. I think I know what the problem is. Accessing just the I ran into this myself and was thinking of a making a change to firestorter to mitigate this. I was thinking of introducing a property called As temporary solution you could try adding the get isLoading() {
const { data, fetching } = this;
return fetching;
} Let me know whether that helps. |
@IjzerenHein Thanks. For now my solution works with setting mode = on, but I'm looking forward to using the new isLoading getter. 👍for using the is* prefix 😄 |
Hi, this should be fixed by using the new |
I can't reproduce this anymore on v0.12.1 |
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 thepath
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:
The problem seems to stem from the fact that I'm passing down the observable Document as-is.
If I instead do this (map it to my own non-observable typed document structure), all is ok:
The component does nothing more then de-structure some of the data props and renders them.
What might be causing this issue you think?
The text was updated successfully, but these errors were encountered: