mirror of
https://github.com/brianlovin/security-checklist.git
synced 2026-03-11 08:55:31 +00:00
Fixed flow errors
This commit is contained in:
parent
c09feafde8
commit
9749603acd
2 changed files with 15 additions and 12 deletions
|
|
@ -18,17 +18,20 @@ type State = {
|
|||
|
||||
export class Apps extends React.Component<Props, State> {
|
||||
state = { overflowExpanded: false, contentHeight: 2000, };
|
||||
expandContentContainer: { current: null | HTMLDivElement }
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: Props) {
|
||||
super(props)
|
||||
if (!this.props.resource.apps) return null;
|
||||
|
||||
this.expandContentContainer = React.createRef();
|
||||
|
||||
}
|
||||
|
||||
handleExpand = () => {
|
||||
let expandContentHeight = this.expandContentContainer.current.scrollHeight;
|
||||
let expandContentHeight =
|
||||
this.expandContentContainer.current
|
||||
? this.expandContentContainer.current.scrollHeight
|
||||
: this.state.contentHeight;
|
||||
|
||||
this.setState({
|
||||
contentHeight: expandContentHeight,
|
||||
|
|
@ -41,7 +44,7 @@ export class Apps extends React.Component<Props, State> {
|
|||
render() {
|
||||
let appList = this.props.resource.apps;
|
||||
let overflowAppList;
|
||||
if (appList.length > 3) {
|
||||
if (appList && appList.length > 3) {
|
||||
overflowAppList = appList.slice(3, appList.length);
|
||||
appList = appList.slice(0, 3);
|
||||
}
|
||||
|
|
@ -52,7 +55,7 @@ export class Apps extends React.Component<Props, State> {
|
|||
return (
|
||||
<AppsContainer overflowExpanded={overflowExpanded}>
|
||||
<SectionHeading>Apps</SectionHeading>
|
||||
{appList.map(app => (
|
||||
{appList && appList.map(app => (
|
||||
<AppRow key={app.name} app={app} />
|
||||
))}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ type State = {
|
|||
|
||||
class ChecklistItem extends React.Component<Props, State> {
|
||||
state = { isChecked: false, isLoading: true, isCollapsed: true, contentHeight: 2000, };
|
||||
contentContainer: { current: null | HTMLDivElement }
|
||||
|
||||
constructor(props) {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
this.contentContainer = React.createRef();
|
||||
|
|
@ -47,9 +48,8 @@ class ChecklistItem extends React.Component<Props, State> {
|
|||
});
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps, prevState) {
|
||||
|
||||
if (prevState.isLoading && !this.state.isLoading) {
|
||||
componentDidUpdate(prevProps: Props, prevState: State) {
|
||||
if (prevState.isLoading && !this.state.isLoading && this.contentContainer.current) {
|
||||
return this.setState({
|
||||
contentHeight: this.contentContainer.current.scrollHeight,
|
||||
})
|
||||
|
|
@ -65,11 +65,11 @@ class ChecklistItem extends React.Component<Props, State> {
|
|||
|
||||
uncollapse = () => {
|
||||
this.setState(state => ({ isCollapsed: !state.isCollapsed }));
|
||||
this.contentContainer.current.focus();
|
||||
this.contentContainer.current && this.contentContainer.current.focus();
|
||||
};
|
||||
|
||||
handleAppsExpand = appsContainerHeight => {
|
||||
return this.setState({
|
||||
handleAppsExpand = (appsContainerHeight: number) => {
|
||||
return this.contentContainer.current && this.setState({
|
||||
contentHeight: this.contentContainer.current.scrollHeight + appsContainerHeight,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue