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

Loading...

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 (
      
        { isAuthenticated ? (
          

Solutions/Answers:

Answer 1:

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

Answer 2:

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 />

References

Loading...