Demon
Demon

Reputation: 826

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.

Upvotes: 4

Views: 1111

Answers (1)

Victor
Victor

Reputation: 4199

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'

Upvotes: 9

Related Questions