Bring State Machine to React Component
Since State Machine is sexy, and especially semantic for express STATE of Component
Describe Component with semantic and extensible STATE
import * as React from 'react';
import StatefulComponent, {
ViewState,
IStatefulComponentProps,
IStatefulComponentState,
} from 'stateful';
interface AppProps extends IStatefulComponentProps {}
interface AppState extends IStatefulComponentState {}
class App extends StatefulComponent<ViewState, AppProps, AppState> {
componentDidMount() {
setTimeout(() => {
this.setViewState(ViewState.LOADING);
}, 3000);
}
render() {
const { viewState } = this.state;
return <div className="App">{viewState}</div>;
}
}
export default App;
https://academy.realm.io/posts/sommer-panage-writing-your-ui-swiftly/ https://github.com/aschuch/StatefulViewController