Framework Features
- [x] 1. Highlighting framework frames in the call stack. More work to do here.
- [ ] 2. Show component names in the call stack. React team excited about this. Right now we show filenames. They want to map it to something semantic to the framework. Would be unique. #3792
- [x] 3. Showing framework components in the source tree.
- [x] 4. Previewing library objects on hover. Custom formatters with a nice navigation UI. (Sam)
- [x] 5. Show component instances in the sidebar. New pane showing all instances of a component.
5. Show component instances in the sidebar. New pane showing all instances of a component.
diff --git a/src/components/SecondaryPanes/index.js b/src/components/SecondaryPanes/index.js
index a801f64..8afc2e5 100644
--- a/src/components/SecondaryPanes/index.js
+++ b/src/components/SecondaryPanes/index.js
@@ -142,6 +142,26 @@ class SecondaryPanes extends Component<Props> {
];
}
+ getComponentItem() {
+ if (!sourceMetaData.isReactComponent) {
+ return null;
+ }
+
+ const componentName = //borrow preview's extra field which has the displayName
+ const preview = // borrow what the preview does w/ the Object Inspector
+
+ return {
+ header: componentName
+ className: "scopes-pane",
+ component: preview,
+ opened: prefs.scopesVisible,
+ onToggle: opened => {
+ prefs.scopesVisible = opened;
+ },
+ shouldOpen: isPaused
+ };
+ }
+
getScopeItem() {
const isPaused = () => !!this.props.pauseData;
@@ -243,6 +263,10 @@ class SecondaryPanes extends Component<Props> {
const items: Array<SecondaryPanesItems> = [];
if (!this.props.horizontal) {
+ items.unshift(this.getComponentItem());
+ }
+
+ if (!this.props.horizontal) {
items.unshift(this.getScopeItem());
}

It's absolutely okay to have several ppl working on it as long as we're talking and sharing what we learn :)
I am trying to finish the 5th.
here are some notes on how we get the react preview.
diff --git a/src/components/Editor/Preview/Popup.js b/src/components/Editor/Preview/Popup.js
index 89c0177..abca23b 100644
--- a/src/components/Editor/Preview/Popup.js
+++ b/src/components/Editor/Preview/Popup.js
@@ -39,6 +39,8 @@ type Props = {
extra: string
};
+// This is how we see if it is a react component
+// we can move this method to a better spot :)
function isReactComponent(roots) {
return roots.some(root => root.name === "_reactInternalInstance");
}
@@ -113,6 +115,8 @@ export class Popup extends Component<Props> {
return null;
}
+ // This is where we render the React Preview
+ // note that the extra field has the display name
if (isReactComponent(roots)) {
if (typeof extra !== "undefined") {
reactHeader = (
@@ -122,6 +126,11 @@ export class Popup extends Component<Props> {
);
}
+ // all we do at the moment is filter the component's fields
+ // so that it has ["state", "props"]... in the future we'll want to do more here
+ // also we might want to show the non-react props which sometimes exists
+ // e.g. if you have a dropdown component, you might set `this.button` ...
+ //and we'd want to show button in the preview but i digress :P
roots = roots.filter(r => ["state", "props"].includes(r.name));
}
and a sketch for a new FrameworkComponent file that we can render from the sidebar
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
// @flow
function isReactComponent() {
// copy from Popup
}
type Props = {};
class FrameworkComponent extends Component<Props> {
renderReactComponent() {
const { pause, frame } = this.props;
// we want to get the `this` object from the pause or frame object, can't remember what
const roots = // find this in pause or frame :)
// roots are the roots for the object inspector
// copying the code from Popup.js
(roots = roots.filter(r => ["state", "props"].includes(r.name)));
return this.renderObjectInspector(roots);
// NOTE i haven't gotten the displayName of the react component here
// because it will be shown in the accordion header
}
render() {
if (isReactComponent()) {
return this.renderReactComponent();
}
}
}
FrameworkComponent.contextTypes = {
shortcuts: PropTypes.object
};
export default connect(
state => {
return {
pause: getPause(state),
frame: getSelectedFrame(state)
};
},
dispatch => bindActionCreators(actions, dispatch)
)(FrameworkComponent);
/claim
Thanks for claiming the issue! :wave:
!!! Please check your email and confirm the invitation
Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.
:fox_face: Debugger team!
hi I would like to help me with 5th one
Great @varenya! Jump in and communicate progress
@tobmaster how has the hacking been?
@jasonLaster sure thanks I will go through the docs and reach out if any help needed thanks :)
@jasonLaster I started learning the codebase and talked with @amitzur we both had the issue that also the popup dialog was not working (cause the value passed to the popup is {type:undefined}). Yesterday we haven't seen why it is like that. Afaik Amit wanted to look into that and I wanted to have a look too.
Thanks @tobmaster, that's not good :)
mind sharing an STR. @samuel-peers worked on adding extra so we could see the DisplayName
I'll take a look
I will stop working on this since already few people are working and I got a another issue recommended on slack so I will be going for that.
@varenya feel free to keep hacking on this one too. it's big enough to warrant many eyes
Didn't had the chance to work on this that much yet so i better unclaim for now
/unclaim
/claim
Thanks for claiming the issue! :wave:
Here are some links for getting setup, contributing, and developing. We're always happy to answer questions in slack! If you become busy, feel free to /unclaim it.
:fox_face: Debugger team!
^^^5