airbnb / javascript

JavaScript Style Guide
MIT License
144.79k stars 26.46k forks source link

Inconsistent Code Style Enforcement in React Components #2995

Open bitcooker opened 3 months ago

bitcooker commented 3 months ago

There seems be notable inconsistencies in how code style rules are applied within the React components section.

// Example 2 class AnotherComponent extends React.Component { customMethod() { // logic }

componentWillUnmount() { // logic }

componentDidMount() { // logic } }


- State Initialization:
The initialization of state in constructor methods varies across different examples. Some components use direct state initialization within the constructor, while others use class property syntax.
```javascript
// Example 1
class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      count: 0
    };
  }
}

// Example 2
class MyComponent extends React.Component {
  state = {
    count: 0
  };
}

// Example 2 class MyComponent extends React.Component { handleClick = () => { // logic } }

Medha170 commented 2 months ago

Can you assign this issue to me?

ljharb commented 2 months ago

@Medha170 no, because that's not how open source works. issues don't get assigned, you just make a PR.

prateekbisht23 commented 2 days ago

@bitcooker Would you mind specifying the path to the code you mentioned!?