I am wondering how the common way is to import a huge text to a View. In my case i am developing a React Native App for Android and iOS, and on one of my Views i want to present the "Terms of Use" document. Now when i just import/copy paste it into a Text Component it just can´t be the right solution, especially when i need to use localization to present the needed language. How would i "import" this Text-Block so it is nice formatted and i don´t need to put everything into my View:
<View style={styles.container}>
<Text style={styles.text}> |JSON - Text-file, with about 600 words -> Terms of Use document |</Text>
</View>
To fetch data from local JSON file with React Native, we can import the JSON file with import . import * as React from 'react'; import { View, Text } from 'react-native'; import { Card } from 'react-native-paper'; import customData from './customData. json'; const App = () => { return ( <View> <Text>{JSON.
Importing JSON file in create-react-appcreate-react-app supports importing JSON files right out-of-the-box. For example, you can import a JSON file in the following way: import products from '../path/to/products.
You can use:
import file from './config/TermsAndCondition.json';
then you can treat it as a javascript object:
file.description
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With