69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
![]() |
export {};
|
||
|
// import React from "react";
|
||
|
// import { CoreError, UiErrorState } from "../core/store/base_store";
|
||
|
// import { SelectProjectStore } from "./select_project/presentation/select_project_store";
|
||
|
|
||
|
// export declare type ClassConstructor<T> = {
|
||
|
// new (...args: any[]): T;
|
||
|
// };
|
||
|
// interface MobxReactComponentProps<T extends UiErrorState<CoreError>, ClassConstructor> {
|
||
|
// store: ClassConstructor;
|
||
|
// children: (element: T) => React.ReactElement;
|
||
|
// }
|
||
|
|
||
|
// class UiStateErrorComponent<T extends UiErrorState<CoreError>, K> extends React.Component<
|
||
|
// MobxReactComponentProps<T, K>,
|
||
|
// { store: T | undefined }
|
||
|
// > {
|
||
|
// async componentDidMount(): Promise<void> {
|
||
|
// const store = this.props.store as ClassConstructor<T>;
|
||
|
// console.log(store);
|
||
|
// const s = new store();
|
||
|
// this.setState({ store: s });
|
||
|
// if (this.state !== null) {
|
||
|
// await this.state.store?.init();
|
||
|
// }
|
||
|
// }
|
||
|
// componentWillUnmount(): void {
|
||
|
// if (this.state.store !== undefined) {
|
||
|
// this.state.store.dispose();
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// render() {
|
||
|
// if (this.state !== null) {
|
||
|
// if (this.state.store?.isLoading) {
|
||
|
// return <>Loading</>;
|
||
|
// }
|
||
|
// if (this.state.store !== undefined) {
|
||
|
// return this.props.children(this.state.store);
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// return (
|
||
|
// <div>
|
||
|
// <>{this.props.children}</>
|
||
|
// </div>
|
||
|
// );
|
||
|
// }
|
||
|
// }
|
||
|
|
||
|
// export const ExampleScreen: React.FC = () => {
|
||
|
// return (
|
||
|
// <div>
|
||
|
// <UiStateErrorComponent<SelectProjectStore, {}> store={SelectProjectStore}>
|
||
|
// {(store) => {
|
||
|
// console.log(store);
|
||
|
// return (
|
||
|
// <div>
|
||
|
// {store.projects.map((el) => {
|
||
|
// return <>{el}</>;
|
||
|
// })}
|
||
|
// </div>
|
||
|
// );
|
||
|
// }}
|
||
|
// </UiStateErrorComponent>
|
||
|
// </div>
|
||
|
// );
|
||
|
// };
|