1

How to detect that the current used React (stable/release) version in an application supports concurrent mode ? Let's say you are authoring a library that should target several react versions, and only add concurrent features if they are relevant.

I'm doing a return typeof React.useTransition === "function" but I am hesitant about it.

Thanks in advance.

Incepter
  • 2,711
  • 15
  • 33
  • I'm curious why you need the check, wouldnt version control help? like v1 compitable with react under 18 and v2(with support of concurrent features) works with react 18? – K4ch Dec 16 '21 at 10:11
  • Im preparing a state management library (sync and async with a new paradigm of dynamic and decentralized states) on early phases and i want to support all code bases i work on: concurrent and not. I added support via a read() function that 'suspends' if it detects concurrent mode or falls back to normal mode while printing a warning. The condition i did is working well, but i need to make sure it is common among the community. – Incepter Dec 16 '21 at 12:11
  • Separating with versions should work as well, but the maintenance will add an overhead and future users will need to synchronize react's and the library's versions, which should not be a concern since an easy if else can do the work and only the usage can determine the behavior. – Incepter Dec 16 '21 at 12:14
  • I opened the following issue on react's codebase waiting for a global solution/answer: https://github.com/facebook/react/issues/22964 – Incepter Dec 16 '21 at 12:16

0 Answers0