Skip to main content

v3

This example shows how to apply stillness-component in umi3.x, by rewriting the underlying rendering plugin, to transform switch to achieve a consistent effect

Now that this is a public package, all that is needed is:

yarn add umi-plugin-stillness

Among them, because of some modification to IRoute, when routes has stillness in it, it will become a cached page

Usage Notes:

.umirc.ts
import { defineConfig } from 'umi';

export default defineConfig({
nodeModulesTransform: {
type: 'none',
},
routes: [
{
exact: false,
path: '/',
component: '@/layouts/index',
routes: [
{
exact: false,
path: '/home',
component: '@/pages/home',
stillness: true,
routes: [
{
path: '/home/a',
component: '@/pages/a',
stillness: true,
},
],
},
{ path: '/about', component: '@/pages/about', stillness: true },
{ path: '/list', component: '@/pages/list' },
],
},
],
stillness: {},
});

Also, the stillness-component common api has been imported directly via umi:

import { Offscreen,StillnessIRoute } from 'umi';