CJY0208 / react-activation

Hack <KeepAlive /> for React
https://www.npmjs.com/package/react-activation
MIT License
1.78k stars 140 forks source link

结合umi4中使用,缓存页面存在Select组件和Image组件,触发过select点击事件和图片的预览 。打开新页面回退到缓存页面的时候会出现打开图片预览的弹框和展开Select的选项的问题 #309

Closed hannah-lin-sama closed 4 months ago

hannah-lin-sama commented 5 months ago
import { KeepAlive } from '@umijs/max';
import { Image, Select } from 'antd';
import { useState } from 'react';

const PageTest = () => {
  const [count, setCount] = useState();

  return (
    <div style={{ margin: 40 }}>
      <Select
        value={count}
        options={[
          {
            value: '1',
            label: '选中1'
          },
          {
            value: '2',
            label: '选中2'
          },
          {
            value: '3',
            label: '选中3'
          },
          {
            value: '4',
            label: '选中4'
          }
        ]}
        onChange={(value) => {
          console.log('onChange', value);
          setCount(value);
        }}
      />
      <p>
        {count}
      </p>
      <Image
        height={300}
        width={500}
        src={'https://copyright.bdstatic.com/vcg/creative/cc9c744cf9f7c864889c563cbdeddce6.jpg@h_1280'}
      />
    </div>
  );
};

export default () => <KeepAlive name="test-keepalive"><PageTest /></KeepAlive>;

image

hannah-lin-sama commented 5 months ago

添加autoFreeze={false}解决了 参考#225