Memoize context value (#3786)
This commit is contained in:
parent
31cb3e5422
commit
181e61bedb
2 changed files with 13 additions and 8 deletions
|
@ -34,10 +34,17 @@ export function createPortalGroup() {
|
|||
setOutlet(<>{Object.values(map.current)}</>)
|
||||
}, [])
|
||||
|
||||
const contextValue = React.useMemo(
|
||||
() => ({
|
||||
outlet,
|
||||
append,
|
||||
remove,
|
||||
}),
|
||||
[outlet, append, remove],
|
||||
)
|
||||
|
||||
return (
|
||||
<Context.Provider value={{outlet, append, remove}}>
|
||||
{props.children}
|
||||
</Context.Provider>
|
||||
<Context.Provider value={contextValue}>{props.children}</Context.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue