React component data initialization
koa-cola Use Cola decorator's components to initialize data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| const {Cola} = require('koa-cola/client'); export interface Props { foo: string; } export interface States {} @Cola({ initData : { foo : async ({ params, helpers, store: { dispatch } }) => { return await Promise.resolve('bar'); } } }) class Some_Page extends React.Component<Props, States> { constructor(props: Props) { super(props); } render() { return <div>{this.props.foo}</div>; } } export default Some_Page;
|