Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Show unsupported screen in dev tools for React version < 15.0.0 #16720

Closed
wants to merge 2 commits into from

Conversation

danielhusar
Copy link

@danielhusar danielhusar commented Sep 10, 2019

refs #16462

Screen Shot 2019-09-09 at 20 51 00

Before submitting a pull request, please make sure the following is done:

  1. Fork the repository and create your branch from master.
  2. Run yarn in the repository root.
  3. If you've fixed a bug or added code that should be tested, add tests!
  4. Ensure the test suite passes (yarn test). Tip: yarn test --watch TestName is helpful in development.
  5. Run yarn test-prod to test in the production environment. It supports the same options as yarn test.
  6. If you need a debugger, run yarn debug-test --watch TestName, open chrome://inspect, and press "Inspect".
  7. Format your code with prettier (yarn prettier).
  8. Make sure your code lints (yarn lint). Tip: yarn linc to only check changed files.
  9. Run the Flow typechecks (yarn flow).
  10. If you haven't already, complete the CLA.

Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html

@sizebot
Copy link

sizebot commented Sep 10, 2019

No significant bundle size changes to report.

Generated by 🚫 dangerJS against b86e3a5

Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the place we most likely want to do this check is here:

// Inject any not-yet-injected renderers (if we didn't reload-and-profile)
if (!rendererInterface) {
if (typeof renderer.findFiberByHostInstance === 'function') {
rendererInterface = attach(hook, id, renderer, global);
} else {
rendererInterface = attachLegacy(hook, id, renderer, global);
}

In the else branch (where we call attachLegacy) we should try to detect v14 and older (maybe using the ComponentTree check I mentioned). If we detect an unsupported version, we should:

  1. send a message over the bridge so the frontend knows to show a modal
  2. Not call any of the "attach" methods since they would just runtime error anyway.

store = new Store(bridge, {supportsNativeInspection: false});
store = new Store(bridge, {
supportsNativeInspection: false,
supportsReact: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this param name is a bit confusing. React DevTools always "support React" 😄 We just want to detect an unsupported version.

I think this probably doesn't belong as a store capability.

@@ -130,6 +131,7 @@ function createPanelIfReactLoaded() {
isProfiling,
supportsReloadAndProfile: isChrome,
supportsProfiling,
supportsReact: renderers.get(1) && !!renderers.get(1).ComponentTree,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above comment. I don't think this belongs as a store capability, so this can be reverted 😄

<SettingsModal />
</div>
) : (
<UnsupportedReactVersion />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use the ModalDialogContext to show a message if we detect an unsupported React version. We do a similar thing for React Native in WarnIfLegacyBackendDetected actually. Conceptually the two are kind of the same.

@danielhusar
Copy link
Author

danielhusar commented Sep 11, 2019

Thanks!
I'll take a look at attachRenderer.

@bvaughn bvaughn marked this pull request as ready for review September 11, 2019 22:42
@bvaughn
Copy link
Contributor

bvaughn commented Sep 25, 2019

Closing in favor of #16897

@bvaughn bvaughn closed this Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants