react-native-import

1.0.4 • Public • Published

react-native-import

Easy to manage, optimised and avoid recurring react-native and third-party imports in multiple files.

Install

npm i -S react-native-import

Config

In root file i.e index.js of project, apply this config

import RN, { RNConfig } from 'react-native-import';
import ThirdParty1 from 'third-party1'; //dummy example
import {ThirdParty2} from 'third-party2'; //dummy example
 
RNConfig({
    whiteList: [],  // white list the component you want to import from react-native
                    // default components whitelisted:
                    // ['AppRegistry''View''Text''StyleSheet''Platform']
                    // your whitelist components e.g:
                    // ['Button''Image']
    blackList: [],  // black list the component you dont want to import from whitelisted component
                    // your blacklist components e.g:
                    // ['View''Text']
    thirdParty: {   // third-party libraries except react
      ThirdParty1,
      ThirdParty2,
    }
})
 

Example

import React, {Component} from 'react';
import RN from 'react-native-import';
 
// To access the third party modules you can use RN.ThirdParty1/ RN.ThirdParty2
 
export default class App extends Component {
  render() {
    return (
      <RN.View style={styles.container}>
        <RN.Text>Welcome to React Native Import!</RN.Text>
      </RN.View>
    );
  }
}
 
const styles = RN.StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  }
})
 
 

License

Copyright © 2019, Neel Gala. MIT

Package Sidebar

Install

npm i react-native-import

Weekly Downloads

5

Version

1.0.4

License

MIT

Unpacked Size

3.09 kB

Total Files

3

Last publish

Collaborators

  • neelgala