Create our styles props and get it another component or main file

 Styles.js (It's located inside the Style folder which is inside the Components folder) 

Style.js

import React from "react";
import { StyleSheet } from "react-native";

export const Styles =(props)=>StyleSheet.create({
    mainContainer:{
        backgroundColor:props.colorName,flex:1
    },
 
 
    title: {
        color: 'orange',
        fontSize: 30,
        fontFamily: 'fantasy'
    },
 
})

Get styles propertis

Myfile.js (it's located inside the Components folder)

Myfile.js

import React, { useState } from "react";
import { View, Text} from 'react-native';
import { Styles } from "./Styles/Styles";
function Myfile() {

    return (
<View style={Styles({colorName:'white'}).mainContainer}>
<Text style={Styles('').title}>My Title</Text>
</View>
    );
}

export default Myfile

Comments