Skip to content

fix: replace deprecated componentWillMount and unsafe hasOwnProperty …#32

Open
hamed-zeidabadi wants to merge 1 commit intoreactjsexample:masterfrom
hamed-zeidabadi:fix/deprecated-lifecycle-and-hasOwnProperty
Open

fix: replace deprecated componentWillMount and unsafe hasOwnProperty …#32
hamed-zeidabadi wants to merge 1 commit intoreactjsexample:masterfrom
hamed-zeidabadi:fix/deprecated-lifecycle-and-hasOwnProperty

Conversation

@hamed-zeidabadi
Copy link

Replace deprecated componentWillMount lifecycle method with componentDidMount to prevent memory leaks and follow React best practices.

Also replace direct hasOwnProperty calls with Object.prototype.hasOwnProperty.call() to avoid issues with objects that don't inherit from Object.prototype or have overridden hasOwnProperty method.

Changes:

  • Move history.listen setup from componentWillMount to componentDidMount
  • Replace data.hasOwnProperty() with Object.prototype.hasOwnProperty.call()
  • Replace params.hasOwnProperty() with Object.prototype.hasOwnProperty.call()

This fixes potential memory leaks and follows ESLint no-prototype-builtins rule.

…usage

Replace deprecated componentWillMount lifecycle method with componentDidMount
to prevent memory leaks and follow React best practices.

Also replace direct hasOwnProperty calls with Object.prototype.hasOwnProperty.call()
to avoid issues with objects that don't inherit from Object.prototype or have
overridden hasOwnProperty method.

Changes:
- Move history.listen setup from componentWillMount to componentDidMount
- Replace data.hasOwnProperty() with Object.prototype.hasOwnProperty.call()
- Replace params.hasOwnProperty() with Object.prototype.hasOwnProperty.call()

This fixes potential memory leaks and follows ESLint no-prototype-builtins rule.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant