Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

fix fetching initial state from redux store #30

Merged
merged 1 commit into from
Dec 14, 2016
Merged

Conversation

marzelin
Copy link

Subscription takes place after Redux store initialization action so listener won't update component's initial state - the app state needs to be synchronized manually.

@vkarpov15
Copy link
Collaborator

Thanks for the PR. What effects does this issue have?

@marzelin
Copy link
Author

In your checkbox example where the checkbox is initially in unchecked state it's not because the state in redux store is false (the store state is not fetched at this point), but because this.state is an empty object as initially declared in constructor (you can see it in react tools). The end result is still the same - checkbox is initially rendered as unchecked, but for quite different reasons.

Knowing that a callback given to store.subscribe() won't be fired on store initialization is a minor detail since normally everybody uses connect() to wire store to components, but still worth noting when playing with Redux's lower level interface.

btw great course.

@vkarpov15
Copy link
Collaborator

Good catch, thanks for your PR 🍻

@vkarpov15 vkarpov15 merged commit 571f93a into gothinkster:01 Dec 14, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants