English | 中文文档
Umi plugin to store initial state globally.
# or yarn
$ npm install @umijs/plugin-initial-state --save
Getting started in 3 steps.
export default {
plugins: [['@umijs/plugin-initial-state', options]],
};
export async function getInitialState() {
return 'Hello World';
}
import React from 'react';
import { useModel } from 'umi';
export default () => {
const { initialState, loading, refresh } = useModel('@@initialState');
return <>{ loading ? 'loading...' : initialState }</>;
};
Full example can find in ./example.
MIT