zhangyuang / ssr

A most advanced ssr framework support React17/React18/Vue2/Vue3 on Earth that implemented serverless-side render specification.
http://doc.ssr-fc.com/
MIT License
2.59k stars 283 forks source link

React扩展Reducer问题 #227

Closed aldabil21 closed 2 years ago

aldabil21 commented 2 years ago

详细描述你的问题

根据文档扩展自定义 Reducer, 以及import store statement这里,框架应该混合自己的default reducer, 和用户自己写的的state/reducer.

只不过在这个情况下,用户不能利用自己创建的store, 因为state, reducer这里总是undefined。实际上是store?.statestore?.reducer

期望的结果

import statement应该包括用户创建的state, reducer

当前使用的版本

6.2.x

复现仓库地址

参考仓库. 我已修改 ReactRoutesType 和 import statements. 如果觉得这个解决方案是可以的,我以下连 PR。

你本人对问题可能的原因判断(如果你能大概判断的话)

或许ssr-declare-routeexport * as store from "@/store/index"的statement (?)

zhangyuang commented 2 years ago

没懂你的具体问题是什么,按照文档示例跑不通?

zhangyuang commented 2 years ago

你这就是把 state,reducer合并到了store,跟单独export state, reducer 有什么区别?

aldabil21 commented 2 years ago

这里 state/reducer总是undefined. 自己创建的store怎么弄也都不会和框架的state/reducer混合的。

zhangyuang commented 2 years ago

总是 undefined 是因为你没导出呀,这里读的就是开发者的 state,reducer

aldabil21 commented 2 years ago

已经导出的就像文档解释的这里console state, reducer const { reducer, state } = Routesconsole store value const { store } = Routes

zhangyuang commented 2 years ago

哦我知道问题了,这里是上次修 vue 的bug的时候把react这种情况忽略了