hox
hox copied to clipboard
State sharing for React components.
使用版本 1.1.4 hox使用 createModal 创建实例,但是没有销毁方法,在 modal 里使用副作用例如监听dom元素没有办法在最后销毁。 建议增加一个销毁方法以便触发 unmount 如果没有别的办法,可以考虑在 render (Executor 的时候多套一层根节点,销毁的时候把数据节点从根节点上移除就能触发 unmount https://github.com/umijs/hox/blob/7f3d67ca9e882f4e8575c555f6b3cb119a3870d0/src/create-model.tsx#L7 ``` export function createModel(hook: ModelHook, hookArg?: P) { const container = new Container(hook); render( {...
在一个页面中使用 多个model来修改页面状态,在第一次使用一个方法同时修改两个状态时,浏览器提出警告。 react ,hox 都是最新的版本。 [userPageModel.md](https://github.com/umijs/hox/files/6307886/userPageModel.md) [userPage.md](https://github.com/umijs/hox/files/6307889/userPage.md) [loading.md](https://github.com/umijs/hox/files/6307892/loading.md)   第一次调用 loadingM.startloading 的方法的时候,会出现浏览器中的警告。 浏览器使用的是chrome,最新版
createModel 创建太多的话会不会有影响
是否是必要的依赖呢?代价似乎太大了 https://bundlephobia.com/[email protected] 
为了让开发者调试更方便,可以做一套dev tools
当和umi的useRequest一起使用时,我在组件最外层配置了UseAPIProvider的onError属性,当接口500时,不执行onError的回调函数 ``` javascript // useUser.js const useUser = () => { const [userInfo, setUser] = useState(); const { run, loading } = useRequest('/api/user', { manual: true }); useEffect(() => {...
使用yarn workspace方式时,yarn build的时候缺少库 @types/testing-library__dom ``` [16:36:03] Using gulpfile ~/../hox/gulpfile.js [16:36:03] Starting 'build'... [16:36:03] Starting 'clean-lib'... [16:36:03] Finished 'clean-lib' after 2.4 ms [16:36:03] Starting 'copy-files'... [16:36:03] Finished 'copy-files' after 78 ms...
看一下这个例子:https://codesandbox.io/s/hox-best-practice-w96lz 在 combinedInc 与 combinedDec 的区别只在于调用外部与外部的 setState 的顺序不同,却导致触发的 effect 次数不同(inc 1 次;dec 2 次,并其中一次是错误的),这影响就很大了。