Титульный знак кнопки должен быть строкой - реагировать на родной
при запуске на устройстве, получающем ошибку, подобную этой ", название прокрутки кнопки должно быть строкой - реагировать на 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);
Ответы
Ответ 1
Я думаю, что вы слишком рано закрыли тег Button.
<Button
style={{fontSize: 20, color: 'green'}}
styleDisabled={{color: 'red'}}
onPress={() => this._handlePress()}> // <-- closed tag here
title="Press Me"
</Button>
Просто закройте тег после атрибута title
<Button
style={{fontSize: 20, color: 'green'}}
styleDisabled={{color: 'red'}}
onPress={() => this._handlePress()}
title="Press Me"
>
Press Me
</Button>
Ответ 2
Название кнопки должно быть написано с ключевым словом
Пример:
<Button
style={{fontSize: 20, color: 'green'}}
styleDisabled={{color: 'red'}}
onPress={() => this._handlePress()}
title="Press Me"
>
</Button>
title= "Нажмите Me" внутри тега кнопки