Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Tools or use a pre-prelease version.

## Usage

### Supporting tools

- The babel plugin [trasnform-react-jsx-source](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-react-jsx-source) is required if you want react devtools to tell you the source file & line number of created react elements. It's display in the bottom of the right panel if the information is present.

Choose a reason for hiding this comment

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

It's display → It's displayed


### Tree View

- Arrow keys or hjkl for navigation
Expand Down
3 changes: 3 additions & 0 deletions backend/getData.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function getData(element: Object): DataType {
var type = null;
var key = null;
var ref = null;
var source = null;
var text = null;
var publicInstance = null;
var nodeType = 'Native';
Expand Down Expand Up @@ -65,6 +66,7 @@ function getData(element: Object): DataType {
if (element._currentElement.key) {
key = String(element._currentElement.key);
}
source = element._currentElement._source;
ref = element._currentElement.ref;
if (typeof type === 'string') {
name = type;
Expand Down Expand Up @@ -111,6 +113,7 @@ function getData(element: Object): DataType {
type,
key,
ref,
source,
name,
props,
state,
Expand Down
1 change: 1 addition & 0 deletions backend/getData012.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function getData012(element: Object): DataType {
type,
key,
ref,
source: null,
name,
props,
state,
Expand Down
1 change: 1 addition & 0 deletions backend/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type DataType = {
type: ?(string | AnyFn),
key: ?string,
ref: ?(string | AnyFn),
source: ?Object,
name: ?string,
props: ?Object,
state: ?Object,
Expand Down
36 changes: 36 additions & 0 deletions frontend/PropState.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var React = require('react');
var decorate = require('./decorate');
var invariant = require('./invariant');


class PropState extends React.Component {
getChildContext() {
return {
Expand All @@ -29,6 +30,23 @@ class PropState extends React.Component {
};
}

renderSource(): ?React.Element {
var source = this.props.node.get('source');
if (!source) {
return null;
}
return (
<div style={styles.source}>
<div style={styles.sourceName}>
{source.fileName}
</div>
<div style={styles.sourcePos}>
:{source.lineNumber}
</div>
</div>
);
}

render(): React.Element {
if (!this.props.node) {
// TODO(jared): style this
Expand Down Expand Up @@ -129,6 +147,8 @@ class PropState extends React.Component {
</DetailPaneSection>}
{this.props.extraPanes &&
this.props.extraPanes.map(fn => fn && fn(this.props.node, this.props.id))}
<div style={{flex: 1}} />
{this.renderSource()}
</DetailPane>
);
}
Expand Down Expand Up @@ -171,4 +191,20 @@ var WrappedPropState = decorate({
},
}, PropState);

var styles = {
source: {
padding: '5px 10px',
display: 'flex',
flexDirection: 'row',
},

sourceName: {
color: 'blue',
},

sourcePos: {
color: '#777',
},
};

module.exports = WrappedPropState;