Skip to content

Commit 4ea7d3c

Browse files
kudljharb
authored andcommitted
[Docs] jsx-no-constructed-context-values: fix invalid example syntax
1 parent 4881bae commit 4ea7d3c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1717
* [`no-typos`]: avoid a crash on bindingless `prop-types` import; add warning ([#2899][] @ljharb)
1818
* [`jsx-curly-brace-presence`]: ignore containers with comments ([#2900][] @golopot)
1919

20+
### Changed
21+
* [Docs] [`jsx-no-constructed-context-values`][]: fix invalid example syntax ([#2910][] @kud)
22+
23+
[#2910]: https://github.com/yannickcr/eslint-plugin-react/pull/2910
2024
[#2906]: https://github.com/yannickcr/eslint-plugin-react/pull/2906
2125
[#2900]: https://github.com/yannickcr/eslint-plugin-react/pull/2900
2226
[#2899]: https://github.com/yannickcr/eslint-plugin-react/issues/2899

docs/rules/jsx-no-constructed-context-values.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ return (
2323
Examples of **correct** code for this rule:
2424

2525
```
26-
const foo = useMemo(() => {foo: 'bar'}, []);
26+
const foo = useMemo(() => ({foo: 'bar'}), []);
2727
return (
2828
<SomeContext.Provider value={foo}>
2929
...
@@ -34,4 +34,4 @@ return (
3434
## Legitimate Uses
3535
React Context, and all its child nodes and Consumers are rerendered whenever the value prop changes. Because each Javascript object carries its own *identity*, things like object expressions (`{foo: 'bar'}`) or function expressions get a new identity on every run through the component. This makes the context think it has gotten a new object and can cause needless rerenders and unintended consequences.
3636

37-
This can be a pretty large performance hit because not only will it cause the context providers and consumers to rerender with all the elements in its subtree, the processing for the tree scan react does to render the provider and find consumers is also wasted.
37+
This can be a pretty large performance hit because not only will it cause the context providers and consumers to rerender with all the elements in its subtree, the processing for the tree scan react does to render the provider and find consumers is also wasted.

0 commit comments

Comments
 (0)