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

Element type is invalid: expected a string. #2336

Closed
GuillaumeMunsch opened this issue Sep 4, 2017 · 3 comments
Closed

Element type is invalid: expected a string. #2336

GuillaumeMunsch opened this issue Sep 4, 2017 · 3 comments

Comments

@GuillaumeMunsch
Copy link

Version

  • react-native-router-flux v4.0.0-beta.21
  • react-native v0.44.2

I'm having issues implementing the new version of the router into my application.
Whatever I try I keep running into this error:

capture d ecran 2017-09-04 a 18 24 02

I did some tests with my app and I even tried removing all my routing but just the fact that I'm upgrading the package to the v4 pops this error out.

I'm sadly out of ideas :/. Do you have any clue what could cause this ?

@luco
Copy link
Contributor

luco commented Sep 4, 2017

Please, post some code.

@GuillaumeMunsch
Copy link
Author

Alright, there it is:

index.ios.js:

import {
  AppRegistry,
} from 'react-native';
import SquareboardMobile from './src';

AppRegistry.registerComponent('SquareboardMobile', () => SquareboardMobile);

./src/index.js:

import React from 'react';
import { Provider } from 'react-redux';
import AppView from './AppView';
import store from './store';

const SquareboardMobile = () => (
  <Provider store={store}>
    <AppView />
  </Provider>
);

export default SquareboardMobile;

./src/AppView.js:

import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
} from 'react-native';
import {
  Scene,
  Router,
  Reducer,
  Stack,
} from 'react-native-router-flux';
import { connect } from 'react-redux';

const getSceneStyle = () => ({
  backgroundColor: '#F5FCFF',
  shadowOpacity: 1,
  shadowRadius: 3,
});

class AppView extends Component {
  constructor(props) {
    super(props);
    this.reducerCreate = this.reducerCreate.bind(this);
  }

  reducerCreate(params) {
    const defaultReducer = new Reducer(params);
    return (state, action) => {
      console.log('ACTION:', action);
      this.props.dispatch(action);
      return defaultReducer(state, action);
    };
  }

  render() {
    return (
      <Router createReducer={this.reducerCreate}>
        <Stack key="root">
          <Scene key="login" component={<Text>Test</Text>} title="INIT" />
        </Stack>
      </Router>
    );
  }
}

export default connect()(AppView);

react-native-router-flux and react-native versions are still the same. The error kind of changed though. I have an additional information. There it is:

capture d ecran 2017-09-05 a 11 38 58

It looks like there is something with the Wrapped component.

@GuillaumeMunsch
Copy link
Author

<Scene key="login" component={<Text>Test</Text>} title="INIT" /> should be <Scene key="login" component={() => <Text>Test</Text>} title="INIT" /> ...

I'm getting blind after hours of debugging ...
Thanks for your time guys

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

2 participants