Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

need support case of 'parent / childs render in the right order' #191

Closed
snadn opened this issue Aug 2, 2019 · 9 comments
Closed

need support case of 'parent / childs render in the right order' #191

snadn opened this issue Aug 2, 2019 · 9 comments

Comments

@snadn
Copy link

snadn commented Aug 2, 2019

is there any plan to support case of 'parent / childs render in the right order' https://github.com/mobxjs/mobx-react-lite/blob/master/test/observer.test.tsx#L600

@danielkcz
Copy link
Collaborator

Well, those tests were basically copied over from mobx-react and for some reason, it's commented out. Chances are it's actually working, I don't know. Can you present some real use case with reproduction, please?

@snadn
Copy link
Author

snadn commented Aug 2, 2019

@FredyC my use case is same with the test. when logout, user data become null, and the components use user data which only render when login and control by parent get error.

@danielkcz
Copy link
Collaborator

danielkcz commented Aug 2, 2019

Sorry, I am not sure I follow. That test is somewhat weirdly written and doesn't make much sense to me. I tried to simplify it and it seems to be working. Please tweak that sandbox to reproduce your specific issue.

https://codesandbox.io/s/stupefied-pascal-o6wew

@mweststrate
Copy link
Member

@snadn for verification purposes, you could check if the problem disappears when using observer through mobx-react (mobx-react repackages mobx-react-lite + more goodies, so the rest of the impl will stay the same)

Please note that this issue is a duplicate of #153, so most probably not fixed yet .

As work around, doing the following in your app code before rendering React for the first time should also fix it:

import { configure } from "mobx"
import { unstable_batchedUpdates  } from "react-dom" // or react-native

configure({ reactionScheduler: unstable_batchedUpdates })

source

@snadn
Copy link
Author

snadn commented Aug 3, 2019

@mweststrate thanks, I will check later. I use mobx-react and mobx-react-lite in my project. I came across this problem when I use mobx-react-lite, and no problem when use mobx-react.

@snadn
Copy link
Author

snadn commented Aug 5, 2019

@FredyC I reproduced this problem with mobx@4.13.0 mobx-react-lite@1.4.1 and async action.
https://codesandbox.io/s/brave-khayyam-we8ds
It's ok with mobx@4.13.0 mobx-react@6.1.1.
https://codesandbox.io/s/awesome-merkle-08slt

@mweststrate and

import { unstable_batchedUpdates } from "react-dom"; // or react-native
mobx.configure({ reactionScheduler: unstable_batchedUpdates });

fix it

@danielkcz
Copy link
Collaborator

Ok, thanks for repro, that confirms it's indeed duplicate of #153 so closing here.

@snadn
Copy link
Author

snadn commented Aug 5, 2019

I need to send a request to the server before logout

@mweststrate
Copy link
Member

mweststrate commented Aug 5, 2019 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants