Eslint-plugin-react: Prefer stateless function does not detect the use of redux.

Created on 22 Apr 2019  路  1Comment  路  Source: yannickcr/eslint-plugin-react

For example when I have a component like this

class SomeComponent extends Component {

render() {
  const { someState1, someState2 } = this.props
  return( <View>
                  <Component1 prop1={someState1} />
                  <Component2 prop2 ={someState2}} />
            </View>
         );


      }
}

const mapStateToProps = state =>({
   someState1: state.action.someState1,
   someState2:state.action.someState2
});

export default connect(mapStateToProps)(SomeComponent);

Even though the rule says it detects the use of local states, constructors, or render returning something other than JSX before triggering the warning. For some reason it does not detect the use of redux and says it should be a pure function, especially when the redux states are being passed down. I just want to know if this is a bug or if this is intentional. Thank you.

question

Most helpful comment

It should be a pure function - that you're calling your props "state" doesn't make them state, they're just props. redux has state, but SomeComponent does not.

>All comments

It should be a pure function - that you're calling your props "state" doesn't make them state, they're just props. redux has state, but SomeComponent does not.

Was this page helpful?
0 / 5 - 0 ratings