Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add React Performance checks for array-literal and object-literal props. #159

Closed

Conversation

darthtrevino
Copy link

In the same vein as the jsx-no-lambda rule, any dynamic expression, such as array or object expressions, can cause downstream components that adhere to the pure interface to re-render. Array and property literals created in the render() cycle will not have reference equality across renders, which may lead to unnecessary re-renderings.

This PR is a bit of a WIP, but might be good enough for a first pass. Here are some things we could check for in addition to basic literals in properties:
-[ ] Inspect spread-props for dynamic object/array/lambda expressions
-[ ] Inspect render() methods for dynamic object/array/lambda expressions
-[ ] If an component has a prop type that isn't a primitive or a function, emit a warning about implementing shouldComponentUpdate

@palantirtech
Copy link
Member

Thanks for your interest in palantir/tslint-react, @darthtrevino! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

@darthtrevino
Copy link
Author

darthtrevino commented May 7, 2018

I've published the new rules under tslint-react-perf. The source is at the source is [here]: https://github.com/darthtrevino/tslint-react-perf). If/when the rules are there adopted by tslint-react, I'll deprecate the project.

It's evolved a bit since the PR (it checks spread attrs and ternary operators), so I've added implementations of the no-lambda and no-bind rules here as well

@adidahiya
Copy link
Contributor

Closing due to inactivity and age. See #210

@adidahiya adidahiya closed this Aug 1, 2019
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.

3 participants