Skip to content

Conversation

@leops
Copy link
Contributor

@leops leops commented Apr 13, 2021

The React DevTools parses the semver string passed to injectIntoDevTools to detect the features available in the underlying react-reconciler instance (one such example can be found here). These checks are used for instance to decide whether to enable support for hooks or suspense in the UI.

This PR changes the advertised version number to that of an equivalent React version to the react-reconciler library being used (right now the current Reconciler version is 0.26.2, which I approximately mapped to 17.0.1).

There are a few pros and cons to this change that I can think of, the obvious pros being that it makes the development experience generally better as it unlocks all the features of the devtools, while the two main problems this creates are:

  • The react-reconciler version advertised to the devtools is now wrong. On top of my head this this version number is only displayed at the bottom of the components stack, but it could still be misleading to see a different version number than the one you expect when hunting for a bug.
  • The react and react-reconciler versions are tightly correlated, yet the two packages have very different version numbering schemes. This means as it stands now there is no way to automatically derive a React version number from the version of the react-reconciler package, and it will have to be updated by hand when react-reconciler is updated. Failure to do so should have minimal impact however, as it only means that support for potential new features will not be enabled in the devtools, but shouldn't generally cause anything to break.

Obviously a better, long term fix would be to have react-reconciler pass its own version alongside the renderer's to the devtools, but in the short term this sounded like an acceptable fix (and if this is ever fixed in React itself I guess it should be enough to just revert this PR)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 13, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c15aa60:

Sandbox Source
example Configuration

@joshuaellis
Copy link
Member

So for the common human not clued up in how dev-tools works (a.k.a me) with react-reconciler, we need to pass the version of react not the version of the library using the reconciler? So in the case of react-dom if they weren't in sync, it would still pass the version of react?

@drcmda
Copy link
Member

drcmda commented Apr 13, 2021

yeah, i thought we're supposed to put ... um, our own version in there. :-D so i noticed that often features aren't available and always was scratching my head, so this is all that's needed?

btw why 17.0.1 and not 17.0.2? in the file you linked it seems we'd miss a lot of integrations

@leops
Copy link
Contributor Author

leops commented Apr 13, 2021

@joshuaellis I used "react" as an umbrella for all officially supported React Renderers: React DOM, React ART and React Native. All of these use a shader ReactVersion constant in the facebook/react monorepo, and so for instance the renderer for React Native 0.64.0 is registered here as react-native-renderer@17.0.1-4e5d7faf5

@leops
Copy link
Contributor Author

leops commented Apr 13, 2021

@drcmda In theory, yes that version number should absolutely be at the discretion of the library. Unfortunately in practice the devtools using it to choose how to parse the structure of the internal fiber object means it's not there yet. I'm thinking of opening an issue for react, unless of course you'd rather do it yourself as a renderer maintainer. As for the using 17.0.1 instead of 17.0.2 that's a mistake on my part, I'll push a new commit to update that

@leops
Copy link
Contributor Author

leops commented Apr 13, 2021

One thing I'm thinking of with regards to the displayed version number for the library in the devtools being wrong is whether it would break anything to include the version number of react-three-fiber as a prelease tag, so the version number would be something like 17.0.2-react-three-fiber.6.0.13. React Native is doing this so I'm guessing it should work, but I'm not sure whether version numbers that work like user agent strings are actually desirable ...

@drcmda drcmda merged commit ef2355c into pmndrs:master Apr 14, 2021
@drcmda
Copy link
Member

drcmda commented Apr 14, 2021

I'm thinking of opening an issue for react

please do, that would be much appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants