Skip to content
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

Switch/selector equivalent for v4 #3003

Closed
tmaly1980 opened this issue Apr 19, 2018 · 2 comments
Closed

Switch/selector equivalent for v4 #3003

tmaly1980 opened this issue Apr 19, 2018 · 2 comments

Comments

@tmaly1980
Copy link

tmaly1980 commented Apr 19, 2018

I've got the most recent RNRF 4.0.0.beta-28 , and migrating from v3 . The docs say that Switch is deprecated, but what is an example for v4 that does the same effect? For example this is v3:

<Scene
  hideNavBar={true}
  key="root"
  tabs={true}
  title="Main"
  component={connect(state=>({auth:state.auth, app:state.app}))(Switch)}
  selector={props=>!props.app.persisted ? "wait" : props.auth.token ? "loggedIn" : "auth"}
>

Basically, if redux has app.persisted truthy, show 'wait', otherwise show 'loggedIn' if auth.token is set, otherwise default to 'auth'.

The migration does says "Switch is removed - you may use onEnter/onExit handlers for more flexible logic." - but I don't see any examples, not even in the example app.

How do I rewrite this to work with v4?

@sofwu
Copy link

sofwu commented May 15, 2018

+1

@aksonov
Copy link
Owner

aksonov commented Jun 6, 2018

on, success, failure is v4 equivalent for v3 switch. Please check https://github.com/aksonov/react-native-starter-app as the example

@aksonov aksonov closed this as completed Jun 6, 2018
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

No branches or pull requests

3 participants