Make InspectorSidebar a functional component
Summary: Refactoring a bit to make a change easier. Reviewed By: jknoxville Differential Revision: D19330542 fbshipit-source-id: 5926b110d04d73e109ea287cacd4e120ea8c9986
This commit is contained in:
committed by
Facebook Github Bot
parent
ee12a4549c
commit
f78851922e
@@ -94,9 +94,8 @@ type Props = {
|
|||||||
logger: Logger;
|
logger: Logger;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class Sidebar extends Component<Props> {
|
const Sidebar: React.FC<Props> = (props: Props) => {
|
||||||
render() {
|
const {element} = props;
|
||||||
const {element} = this.props;
|
|
||||||
if (!element || !element.data) {
|
if (!element || !element.data) {
|
||||||
return <NoData grow>No data</NoData>;
|
return <NoData grow>No data</NoData>;
|
||||||
}
|
}
|
||||||
@@ -104,12 +103,7 @@ export default class Sidebar extends Component<Props> {
|
|||||||
const sections: Array<any> =
|
const sections: Array<any> =
|
||||||
(SidebarExtensions &&
|
(SidebarExtensions &&
|
||||||
SidebarExtensions.map(ext =>
|
SidebarExtensions.map(ext =>
|
||||||
ext(
|
ext(props.client, props.realClient, element.id, props.logger),
|
||||||
this.props.client,
|
|
||||||
this.props.realClient,
|
|
||||||
element.id,
|
|
||||||
this.props.logger,
|
|
||||||
),
|
|
||||||
)) ||
|
)) ||
|
||||||
[];
|
[];
|
||||||
|
|
||||||
@@ -135,27 +129,27 @@ export default class Sidebar extends Component<Props> {
|
|||||||
}
|
}
|
||||||
sections.push(
|
sections.push(
|
||||||
<InspectorSidebarSection
|
<InspectorSidebarSection
|
||||||
tooltips={this.props.tooltips}
|
tooltips={props.tooltips}
|
||||||
key={extraSection}
|
key={extraSection}
|
||||||
id={extraSection}
|
id={extraSection}
|
||||||
data={data}
|
data={data}
|
||||||
onValueChanged={this.props.onValueChanged}
|
onValueChanged={props.onValueChanged}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sections.push(
|
sections.push(
|
||||||
<InspectorSidebarSection
|
<InspectorSidebarSection
|
||||||
tooltips={this.props.tooltips}
|
tooltips={props.tooltips}
|
||||||
key={key}
|
key={key}
|
||||||
id={key}
|
id={key}
|
||||||
data={element.data[key]}
|
data={element.data[key]}
|
||||||
onValueChanged={this.props.onValueChanged}
|
onValueChanged={props.onValueChanged}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sections;
|
return <>{sections}</>;
|
||||||
}
|
};
|
||||||
}
|
export default Sidebar;
|
||||||
|
|||||||
Reference in New Issue
Block a user