Skip to content

Conversation

@hristo-kanchev
Copy link
Contributor

@hristo-kanchev hristo-kanchev commented Aug 30, 2019

Fixes: #16466 and #16679

Description:
We are now changing the context label in DevTools based on if the component is using the legacy way of adding context.

@hristo-kanchev hristo-kanchev changed the title [DevTools] Legacy Context [DevTools] [Context] Legacy Context Aug 30, 2019
@sizebot
Copy link

sizebot commented Aug 30, 2019

No significant bundle size changes to report.

Generated by 🚫 dangerJS against de31745

@gaearon
Copy link
Collaborator

gaearon commented Aug 30, 2019

Is it possible to add some sort of a test?

@hristo-kanchev
Copy link
Contributor Author

Is it possible to add some sort of a test?

Tests ✅

@hristo-kanchev
Copy link
Contributor Author

@gaearon Did you manage to check the tests?

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.

Thanks! This looks nice. :)

canViewSource = true;
if (stateNode && stateNode.context != null) {
context = stateNode.context;
const shouldHideContext =
Copy link
Contributor

Choose a reason for hiding this comment

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

This could probably use an explanatory inline comment. (I'll add one.)

import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
import type Store from 'react-devtools-shared/src/devtools/store';
import React, {Component, createContext} from 'react';
import {Fragment} from '../../../../../../../../../../Applications/WebStorm.app/Contents/plugins/JavaScriptLanguage/jsLanguageServicesImpl/flow/react';
Copy link
Contributor

Choose a reason for hiding this comment

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

😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Freakin' WebStorm 😆 #NeverTrustYourEditor

@bvaughn
Copy link
Contributor

bvaughn commented Sep 10, 2019

@gaearon Did you manage to check the tests?

What's this comment about? Is this PR safe to merge or do we need to check on something first?

@gaearon
Copy link
Collaborator

gaearon commented Sep 10, 2019

I think this was meant as “@gaearon can you review again now that tests were added”. Lgtm

canViewSource: type === ElementTypeClass || type === ElementTypeFunction,

// Only legacy context exists in legacy versions.
hasLegacyContext: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we also hide empty one though in the legacy mode?

Copy link
Contributor

Choose a reason for hiding this comment

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

This value isn't used to hide the context label in the front end.. It just specifies whether the context is modern vs legacy. I guess it's a little weird to have a boolean value for this. Maybe we should use an enum? context type: none, modern, legacy.

Anyway, an empty legacy context won't be shown on the frontend because the InspectedElementTree component hides itself if the value it's passed is null or an empty object.

@bvaughn bvaughn merged commit 4ef6387 into facebook:master Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment