Skip to content

Destructuring props in react #1918

@JPeer264

Description

@JPeer264
  • eslint-config-airbnb: 17.1.0
  • eslint: 5.6.0

I have a container with redux in my application. I am calling the in the connect assigned prop in componentDidMount where the eslint error react/destructing-assignment appears. But when I destruct the prop, then I have a name collision with startup. Is this the wanted behavior? Or is it preferred to name the prop differently when binding? I couldn't find anything in the style guide according to this.

This exact same code worked fine with another project with v15.1.0

import React, { PureComponent } from 'react';
import { View } from 'react-native';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';

import { startup } from '../../redux/appStatus/appStatus.actions';

class App extends PureComponent {
  componentDidMount() {
	// this here is an error
    this.props.startup();
  }

  render() {
    return <View />;
  }
}

const mapDispatchToProps = dispatch => bindActionCreators({
  startup,
}, dispatch);

export default connect(undefined, mapDispatchToProps)(App);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions