So I have this:
class Selection extends React.Component {state = { role1: true, role2: false}...
Which I want to export to file2 which looks like:
class SignUpAdrress extends React.Component {handlePress = () => { if(role1){ // <- Here's where I want it this.props.navigation.replace('SignupPayment') }else{ this.props.navigation.replace('Login') }};...
How can I do this if these components are not father-child? I've tried using React context which went somehting among the lines:
file1
export let isRole1 = React.createContext({ Role1: true, Role2: false})class Selection extends React.Component {state = { Role1: true, Role2: false}
File 2
import {isRole1} from './File1';class SignUpAdrress extends React.Component {handlePress = () => {<isRole1.consumer> if(role1){ this.props.navigation.replace('SignupPayment') }else{ this.props.navigation.replace('Login') }</isRole1.consumer>};