the title prop of a button must be a string - react native

react-native, reactjs

Solution

I think you have closed the Button tag too early.

<Button
  style={{fontSize: 20, color: 'green'}}
  styleDisabled={{color: 'red'}}
  onPress={() => this._handlePress()}> // <-- closed tag here
  title="Press Me"
</Button>

Just close the tag after the title attribute

<Button
  style={{fontSize: 20, color: 'green'}}
  styleDisabled={{color: 'red'}}
  onPress={() => this._handlePress()}
  title="Press Me"
>
  Press Me
</Button>

Problem

while run on device getting error like this "the title prop of a button must be a string - react native" ``` import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, Button, View } from 'react-native'; export default class sample extends Component { render() { return ( <Button style={{fontSize: 20, color: 'green'}} styleDisabled={{color: 'red'}} onPress={() => this._handlePress()}> title="Press Me" </Button> ); } _handlePress() { console.log('Pressed!'); } } AppRegistry.registerComponent('sample', () => sample); ```

Original source