From eb78605f2973e74336c21ad9d2a1ffc4b1278d2f Mon Sep 17 00:00:00 2001 From: Erwann Mest Date: Thu, 28 Jan 2021 16:35:54 +0100 Subject: [PATCH] Update jsx-no-constructed-context-values.md --- docs/rules/jsx-no-constructed-context-values.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/rules/jsx-no-constructed-context-values.md b/docs/rules/jsx-no-constructed-context-values.md index c0b79de23e..6816b98b59 100644 --- a/docs/rules/jsx-no-constructed-context-values.md +++ b/docs/rules/jsx-no-constructed-context-values.md @@ -23,7 +23,7 @@ return ( Examples of **correct** code for this rule: ``` -const foo = useMemo(() => {foo: 'bar'}, []); +const foo = useMemo(() => ({foo: 'bar'}), []); return ( ... @@ -34,4 +34,4 @@ return ( ## Legitimate Uses 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. -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. \ No newline at end of file +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.