GloballyStyles_fonts_in the project
App.js
import React from 'react'
import { View, Text } from 'react-native'
import Screen1 from './components/Screen1'
import Screen2 from './components/Screen2'
const App = () => {
return (
<>
<Screen1/>
<Screen2/>
</>)
}
export default App
*************************************************************
screen1.js
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'
import GlobalStyle from '../GlobalStyle'
const Screen1 = () => {
return (
<View style={styles.container}>
<Text style={[styles.txt,GlobalStyle.customFont]}> this is screenA</Text>
</View>
)
}
export default Screen1
const styles = StyleSheet.create({
container:{
flex:1,
backgroundColor:'green',
justifyContent:'center',
alignContent:'center'
},
txt:{
fontSize:50
}
})
*******************************************************
screen2.js
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'
import GlobalStyle from '../GlobalStyle'
const Screen2 = () => {
return (
<View style={styles.container}>
<Text style={GlobalStyle.customFont2}> this is screenB</Text>
</View>
)
}
export default Screen2
const styles = StyleSheet.create({
container:{
flex:1,
backgroundColor:'yellow',
justifyContent:'center',
alignContent:'center',
alignSelf:'center',
},
txt:{
fontSize:50
}
})
**************************************************create a file
react-native.config.js
module.export={
assets:['./assets/fonts']
}
**********************************************
download custom fonts like
CaviarDreams_BoldItalic.ttf
*************************************************
package.json
"dependencies": {
"react": "17.0.2",
"react-native": "0.65.1"
},
Comments
Post a Comment