
text-provider-react-native
A react-native component which provides all the string constants using provider pattern
It provides two components:
Install
npm i text-provider-react-native
Usage
- Import the string constants required for the particular presentational component:
const sampleText = ;
- Use the TextProvider to make it available for all the components:
<TextProvider = > <MyPresentationalComponent /></TextProvider>
- Use it inside the presentational component:
<FormattedMessage ="Random Id"/>
const randomId = "Random Id";const values = "valueToBeInjected": "Random Value"; <FormattedMessage = =/>
Works like a format string also. Example JSON:
Then ${valueToBeInjected}
gets replaced with the value specified in values
.
Make sure that a string by the same id
exists in the JSON file.