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

[New] jsx-no-constructed-context-values: add rule for unstable context values #2763

Merged

Commits on Aug 22, 2020

  1. [New] jsx-no-constructed-context-values: add new rule which checks …

    …when the value passed to a Context Provider will cause needless rerenders
    
    Adds a new rule that checks if the value prop passed to a Context Provider will cause needless rerenders. A common example is inline object
    declaration such as:
    ```js
    <Context.Provider value={{foo: 'bar'}}>
    ...
    </Context.Provider>
    ```
    which will cause the Context to rerender every time this is run because the object is defined with a new reference. This can lead to
    performance hits since not only will this rerender all the children of a context, it will also update all consumers of the value. The
    search React does to search the tree can also be very expensive. Some other instances that this rule covers are: array declarations,
    function declarations (i.e. arrow functions), or new class object instantians.
    Dylan Oshima authored and ljharb committed Aug 22, 2020
    Copy the full SHA
    ac98c0f View commit details
    Browse the repository at this point in the history