If I have a Switch component as follows;
<Switch trackColor={{ false: '#e57373', true: '#81c784' }} thumbColor='gray' ios_backgroundColor="gray" onValueChange={(value) => this.setState({ toggle: value })} value={this.state.toggle} />
Can I change the color using a state value I have set e.g
componentDidMount() { backgroundColor = this.props.dataBackgroundColor; primaryColor = this.props.dataPrimaryColor; this.setState({ background_color: backgroundColor }) this.setState({ primary_color: primaryColor }) console.log(this.state.primary_color) // This print correct color}
And then do something like;
<Switch trackColor={{ false: '#e57373', true: this.state.primary_color }} thumbColor='gray' ios_backgroundColor="gray" onValueChange={(value) => this.setState({ toggle: value })} value={this.state.toggle} />
At the moment, no error is thrown but the color is not updated.