I'm making a simple drinking game. When a playing card shows, it's corresponding rule shows below it. All logic to this is in my game.js file. I have another screen, where you can read the rules, and modify them. How can I share the state between two files, so when I modify the rules in the settings.js file, the state would also change in the game.js file? The logic in settings file:
constructor(props) {
super(props);
this.state = {
rule1: 'some rule1',
...
rule13: 'some rule13'
(Also TextInput fields and functions to update the state for each rule)
The logic in my game.js file for the rules right now is:
get rules() {
switch (deck1.deck[this.state.card]) {
case "Ace_of_Spades":
return <Text> some rule1 <Text>
...
case "King_of_Spades":
return <Text> some rule13 <Text>
But I would like to it have the state from the settings.js file for example like this:
get rules() {
switch (deck1.deck[this.state.card]) {
case "Ace_of_Spades":
return {this.state.rule1}
...
case "King_of_Spades":
return {this.state.rule13}
So what would be the easiest and simplest method to just share these states between the 2 files?