Ensured that store from props is initialized with initialize from props. #136
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses the 'provider initialization failure' in #135 .
Problem
When both
store
andinitialize
are passed toLocalizeProvider
, the store is not initialized with the passed payload.If
initialize
is omitted, this problem does not occur because theinitialize()
function is called from userland (from thewithLocalize
-wrapped component). This explicitly dispatches the initialize action.If
store
is omitted, this problem does not occur because there is already code to initialize the passed payload intoLocalizeProvider
's state.Changes
I have added a method that initializes the passed
store
with the passedinitialize
payload (if both are present), and call it incomponentDidMount
. Since there are more things happening incomponentDidMount
as a result of this, I extracted the existing code (subscribe to store) to a separate method. I have also added a test.I think some parts of this diff are caused by prettier not being run somewhere in the past. The new test is at the end of the test file.