MonkeyBonkey
MonkeyBonkey

Reputation: 47871

What is an "element type is invalid" error using a react-native button

Getting the error elment type is invalid: expected a string (for built in components) or a class/function (for composite comonents) but got: undefined

My render function is pretty basic - what am I doing wrong in declaring and rendering the react-native button?

  render() {
    const { dispatch, isAuthenticated, errorMessage, username } = this.props;
    return (
      <View style={styles.outer}>
        { isAuthenticated ? (
          <Button title="Logout" />
        ) : (
          <Button title="Login" />
        )}
      </View>
    );
  }

};

Upvotes: 2

Views: 463

Answers (2)

agenthunt
agenthunt

Reputation: 8678

The default Button component was introduced only in 0.37 version. https://github.com/facebook/react-native/releases/tag/v0.37.0

Upvotes: 1

Matt Aft
Matt Aft

Reputation: 8936

Don't forget the brackets -> title={"Logout"}, title={"Login"}

Edit: nvm, looks like you dont need them for react-native button.

What if you tried something like:

<View style={styles.outer}>
  <Button title={isAuthenticated ? "Logout" : "Login"} />
<View />

Upvotes: 0

Related Questions