/
githubmirror
/
client
Обзор
Документация
Войти
/
githubmirror
/
client
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v5.7.0
shared/util/bootstrapable.tsx
37 строк
986 B
Chris Ball
TypeScript: remove unnecessary ts-ignore, part two (#23506)
06 апр 2020, 03:20
Не верифицирован
06 апр 2020, 03:20
59c852e
Код
Авторство
О чём код?
import * as React from 'react' import {Box, Text} from '../common-adapters' import {globalStyles} from '../styles' export type BootstrapableProp<P extends Object> = | { bootstrapDone: false onBootstrap: () => any } | { bootstrapDone: true originalProps: P } export default function Bootstrapable<P extends Object>( ComposedComponent: React.ComponentType<P> ): React.ComponentClass<BootstrapableProp<P>, void> { return class extends React.Component<BootstrapableProp<P>, void> { componentDidMount() { !this.props.bootstrapDone && this.props.onBootstrap() } render() { if (this.props.bootstrapDone) { return <ComposedComponent {...this.props.originalProps} /> } // TODO(mm) parameterize this return ( <Box style={{...globalStyles.flexBoxColumn, alignItems: 'center', flex: 1, justifyContent: 'center'}}> <Text type="Body">Loading…</Text> </Box> ) } } }