react-keepAlive icon indicating copy to clipboard operation
react-keepAlive copied to clipboard

maxLen这个配置好像没有效果

Open thomas-void0 opened this issue 3 years ago • 2 comments

如下所示:虽然传了maxLen,但是在添加的时候是直接默认取的10这个字面量。 image

thomas-void0 avatar Nov 09 '22 07:11 thomas-void0

是的 在reducer 里面我写死的10。目前还没想好 怎么两个地方公用一个maxLen,后续在考考虑

liuye1296 avatar Nov 14 '22 07:11 liuye1296

目前来说 要想实现这种 有两个方式(我能想到的), 1:如果 maxLen是一个常量 那就提取出一个公有常量就行 这种方式适用 项目中(不是框架通用的方式) 2:使用useContext 抽象出一个全局的配置类似(ant ConfigProvider组件), 这种符合React 的做法 但是我感觉太麻烦了 一个小需求 引入一个额外的全局配置组件 PS: 我们公司的项目我是用第一种

liuye1296 avatar Nov 14 '22 08:11 liuye1296