How to get the state of a reducer within a component with React Native

0

Hello, I'm new to React Native and I'm having trouble getting the status of a reducer for a component I made. it is as follows:

import React from 'react'
import { connect } from 'react-redux'
import { View, Text } from 'react-native'

class Foo extends React.Component {
    render() {
        const foo = !!this.props.isEnabled ? 'sim!' : 'não!';
        return <View><Text>{foo}</Text></View>
    }
}

const mapStateToProps = state => {
    console.log(state);
    return { isEnabled: state.fooReducer.isEnabled }
}

const mapDispatchToProps = {}

export default connect(mapStateToProps, mapDispatchToProps)(Foo);

The redux is working and I can see the state change from the console.log() I put in mapStateToProps I just can not pass that state to the component and use it to manipulate the render.

What do I need to do to use this state inside the render?

    
asked by anonymous 06.11.2018 / 20:56

1 answer

1

Theoretically the part of the component is working, are you using combine reduce ? If you are not, you do not need to specify what reduce is using after variable estate , ex : state."REDUCER".variavel . Attempts to access only the state from the console.log , if an unexpected value comes in it may be some redux setting that you did not set wrong ex to store provider , reduce etc.     

10.11.2018 / 07:45