Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Import

Can we use single keyword instead of '' import { Text, TextInput, Button, StyleSheet, View } from 'react-native'; " in react native? Is there any options available Single keyword for "Text, 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'
  }
});
like image 657
Shalitha Jayamal Avatar asked Jan 14 '20 20:01

Shalitha Jayamal


1 Answers

You could import ReactNative from 'react-native' and use them as <ReactNative.View/> and so on, but I wouldn't recommend that. It's not how 99% of RN devs would expect it to read.

like image 103
Andy Tran Avatar answered Sep 18 '22 00:09

Andy Tran