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

Warning: Failed prop type: Invalid prop scenes of type function supplied to Router, expected a single ReactElement. #2187

Closed
oleksiivorochenko opened this issue Aug 4, 2017 · 4 comments
Labels

Comments

@oleksiivorochenko
Copy link

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.16
  • react-native v0.46.4

app.js

function mapStateToProps(state) {
  return {
    appData: state.appData
  };
}

function mapDispatchToProps(dispatch) {
  return {
    getData: bindActionCreators(getData, dispatch)
  };
}

const myConnectedSideBarConponent = connect(mapStateToProps, mapDispatchToProps)(SideBar);
const myConnectedHomeScreenConponent = connect(mapStateToProps, mapDispatchToProps)(HomeScreen);
const myConnectedMainScreenConponent = connect(mapStateToProps, mapDispatchToProps)(MainScreen);

const scenes = Actions.create(
  <Scene key="drawer" drawer contentComponent={myConnectedSideBarConponent}>
    <Scene key="root" hideNavBar hideTabBar>
      <Scene key="mainScreen" component={myConnectedMainScreenConponent} title="" initial/>
      <Scene key="homeScreen" component={myConnectedHomeScreenConponent} title=""/>      
    </Scene>
  </Scene>
);

const store = configureStore();

const ConnectedApp = connect(mapStateToProps, mapDispatchToProps)(Router);

export default class App extends Component {
        render = () => {
            return (
                <Provider store={store}>
                    <ConnectedApp  scenes={scenes} />
                </Provider>
            );
        }
    }

I get Warning after each restart of the application :
Warning: Failed prop type: Invalid prop scenes of type function supplied to Router, expected a single ReactElement.

08-04 15:19:52.500 5613 5884 W ReactNativeJS: in Router (created by Connect(Router))

08-04 15:19:52.500 5613 5884 W ReactNativeJS: in Connect(Router) (at app.js:69)

08-04 15:19:52.500 5613 5884 W ReactNativeJS: in Provider (at app.js:68)

08-04 15:19:52.500 5613 5884 W ReactNativeJS: in App(at renderApplication.js:35)

08-04 15:19:52.500 5613 5884 W ReactNativeJS: in RCTView (at View.js:133)

08-04 15:19:52.500 5613 5884 W ReactNativeJS: in View (at AppContainer.js:98)

08-04 15:19:52.500 5613 5884 W ReactNativeJS: in RCTView (at View.js:133)

08-04 15:19:52.500 5613 5884 W ReactNativeJS: in View (at AppContainer.js:97)

08-04 15:19:52.500 5613 5884 W ReactNativeJS: in AppContainer (at renderApplication.js:34)

Thanks for help!

@pewh
Copy link

pewh commented Aug 7, 2017

Remove Actions.create, just use () instead.

const scenes = (
  <Scene key="drawer" drawer contentComponent={myConnectedSideBarConponent}>
    <Scene key="root" hideNavBar hideTabBar>
      <Scene key="mainScreen" component={myConnectedMainScreenConponent} title="" initial/>
      <Scene key="homeScreen" component={myConnectedHomeScreenConponent} title=""/>      
    </Scene>
  </Scene>
);

Then convert <ConnectedApp scenes={scenes} /> into <ConnectedApp>{scenes}</ConnectedApp>

@oleksiivorochenko
Copy link
Author

I did everything as you wrote. Warning disappeared. As a result, the application crashes. In the console I see that there is a bunch of requests to the API via Reducer. I encountered this problem earlier and solved it with the help of "Actions.create"

@aksonov aksonov added the bug label Aug 7, 2017
@aksonov
Copy link
Owner

aksonov commented Aug 7, 2017

@avorochenko It seems to be a bug with PropTypes. Please use navigator={scenes} for now

@oleksiivorochenko
Copy link
Author

oleksiivorochenko commented Aug 7, 2017

@aksonov @pewh thanks for help!

@aksonov aksonov closed this as completed in 1a1053d Aug 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants