Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Central style sheet for react native?

I am learning how develop react native development and I am curious if you could put all the styles into one style.js file and then export it which allow all the components to be able to use the styles.

like image 682
Demon Avatar asked Jan 04 '23 22:01

Demon


1 Answers

Yes you can. u can write styles in seperate file.

import React, { Component, PropTypes } from 'react';
import { StyleSheet } from 'react-native';

var styles = StyleSheet.create({
  ...
});

module.exports = styles;

Then import it in componnet class like

import styles from './styles'
like image 131
Victor Avatar answered Jan 06 '23 12:01

Victor