Реагировать на собственный импорт - PullRequest
2 голосов
/ 14 января 2020

Можем ли мы использовать одно ключевое слово вместо '' import {Text, TextInput, Button, StyleSheet, View} из'act-native '; "в реагировать родной? Есть ли варианты доступны одно ключевое слово для" Текст, TextInput, Button, StyleSheet, View "?

import { Button, StyleSheet, View } from 'react-native';

export default class ButtonBasics extends Component {
  _onPressButton() {
    alert('You tapped the button!')
  }

  render() {
    return (
      <View style={styles.container}>

        <View style={styles.buttonContainer}>
          <Button
            onPress={this._onPressButton}
            title="Press Me"
            color="#841584"
          />
        </View>
        <View style={styles.alternativeLayoutButtonContainer}>
          <Button
            onPress={this._onPressButton}
            title="This looks great!"
          />

        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
   flex: 1,
   justifyContent: 'center',
  },
  buttonContainer: {
    margin: 20
  },
  alternativeLayoutButtonContainer: {
    margin: 20,
    flexDirection: 'row',
    justifyContent: 'space-between'
  }
});

1 Ответ

5 голосов
/ 15 января 2020

Вы можете import ReactNative from 'react-native' и использовать их как <ReactNative.View/> и так далее, но я бы не рекомендовал это. Это не то, как 99% разработчиков RN ожидают, что оно прочитает.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...