The title sign of the button should be a string - respond to the native

when launched on a device receiving an error similar to this " , the name of the scroll button should be a string - respond to 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);
+12
source share
2 answers

I think you 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>
+11
source

The name of the button should be spelled with the keyword

Example:

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

title = "Press Me" inside the button tag

+2
source

Source: https://habr.com/ru/post/1676850/


All Articles