Skip to content

Official redux support#3675

Merged
DanielZlotin merged 2 commits into
v2from
officialReduxSupport
Aug 2, 2018
Merged

Official redux support#3675
DanielZlotin merged 2 commits into
v2from
officialReduxSupport

Conversation

@DanielZlotin

@DanielZlotin DanielZlotin commented Aug 2, 2018

Copy link
Copy Markdown
Contributor

The people have spoken.

Usage example:

import {Navigation} from 'react-native-navigation';
import {Provider} from 'react-redux';
import {store} from './store';

import PostsList from './posts/screens/PostsList';

export function registerScreens() {
  Navigation.registerComponentWithRedux('blog.PostsList', () => PostsList, Provider, store);
}

@DanielZlotin
DanielZlotin merged commit 967d7bf into v2 Aug 2, 2018
@DanielZlotin
DanielZlotin deleted the officialReduxSupport branch August 2, 2018 10:58
@rfdc

rfdc commented Aug 3, 2018

Copy link
Copy Markdown

I have tried few option from #1642 and did not work.
What is the solution? Is there an example showing the whole process?
Thanks

@drorbiran

Copy link
Copy Markdown
Contributor

@DanielZlotin

Copy link
Copy Markdown
Contributor Author

Updated with example

@beinginorbit

beinginorbit commented Aug 10, 2018

Copy link
Copy Markdown

@DanielZlotin sorry if this is contained in some other discussion. Was there a technical reason we chose to explicitly provide a method to register components with redux instead of just having everyone figure this out with HOCs (or some other solution)?

Our solution, albeit just starting, is just to have "withStore" HOC.

@DanielZlotin

Copy link
Copy Markdown
Contributor Author

Nothing wrong with doing your own HOCs. Just that lots of people had problems implementing it, so we added this as a "quality of life" feature.

@spencewine

spencewine commented Aug 17, 2018

Copy link
Copy Markdown

@DanielZlotin I'm getting this error: Cannot read property 'componentId of null when using registerComponentWithRedux. Any idea why this would happen?
screen shot 2018-08-17 at 11 43 06 am

edit: It appears getDerivedStateFromProps is getting called before the constructor is initialized so prevState is undefined. Anyone else getting this error when using the new wrapper?

@ywongweb

ywongweb commented Aug 29, 2018

Copy link
Copy Markdown
Contributor

@spencewine Did you managed to find a solution?

I wonder if this error has something to do with the hoist-non-react-statics dependency being on 2.x.x?
react/react#12523 (comment)

edit:
Updated the dependency to 3.x.x , seem to work for now. Will submit a PR once confirmed

@wbercx

wbercx commented Sep 15, 2018

Copy link
Copy Markdown

@DanielZlotin Just wanted to provide some feedback on this. I recently overheard someone suggest the latest version of RNN only supports Redux.

The implementation isn't limited to Redux and, for example, works fine with mobx-react as well. The current naming does not suggest that though.

I think it may make more sense to have this be called registerComponentWithProvider. It seems that captures what this essentially does - it let's you use a Provider.

@DanielZlotin

Copy link
Copy Markdown
Contributor Author

Ah I knew this would happen 🤦 that's why I was reluctant to add this in the first place.
Thanks for the feedback.

@wbercx

wbercx commented Sep 15, 2018

Copy link
Copy Markdown

Nah, it's a fantastic addition, it's just the naming that's is a bit more specific than it needs to be 😁

@DanielZlotin

Copy link
Copy Markdown
Contributor Author

The store argument is kinda redux specific though.. Please open a separate issue with a better api suggestion and we'll deprecate the current api if needed.
Thanks

@alzalabany

Copy link
Copy Markdown

Does this work with new context api providers ?

@creative-git

Copy link
Copy Markdown

any step by step plz ?

@drorbiran

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants