I am new to react native.I learned the benefits of components, embedding external styles.Now I am trying to use global styles.I'd like to use the same styles of text, button throughout my app.
Better not to repeat the styles in every component, I'd like to create separate text.js, button.js under styles package to customizing view styles.
Here is my project structure.I want to import text.js into my index.js.
index.js
import { AppRegistry } from 'react-native';
import React, {Component} from 'react';
import {
Text
} from 'react-native';
import text from './App/styles';
export default class FirstApp extends Component{
render(){
return (
<Text styles={text.p}>Customising React</Text>
);
}
}
AppRegistry.registerComponent('FirstApp', () => FirstApp);
text.js
import{
StyleSheet
} from 'react-native';
export default const text = StyleSheet.create({
p: {
color: 'blue',
fontSize: 14
}
});
Is there any way to import my text.js style into text view in index.js?