Skip to content

useTabster is unsafe for strict mode/concurrent rendering in React 18 #24085

@ling1726

Description

@ling1726

Tabster is created in useMemo from #23811 which is unsafe for concurrent rendering.

In general singletons will be problematic in concurrent rendering because there is no built in way to ensure a singleton constructor is called once:

// all the below call the `createSingleton` function twice on mount
React.useState(() => createSingleton());
React.useMemo(() => createSingleton(), []);

React.useEffect(() => {
  createSingleton();
}, [])

React.useLayoutEffect(() => {
  createSingleton();
}, [])

The above can be observed https://codesandbox.io/s/damp-glade-r7xb2x?file=/src/index.js

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions