Comments (4)
哦哦 不好意思,刚刚仔细 看了下你的官方文档:
https://concentjs.github.io/concent-doc/api/g-configure
有个 configure 函数,应该是能实现 这种功能的,那我 再提个建议咯,你看下修改:
https://concentjs.github.io/concent-doc/api/g-reducer
这个文档中的 reducer 函数,只说明 具体调用时 提供的参数,并没有 说明 主动调用时 参数的类型
比如:上一个 issue 你给我说的 : payload,{renderKey}
另外 像 : ccOption 这种 props 里面的参数,我搜索 api文档 也没看到
希望你有空 能补全下,我准备 开始 推广 公司里的小组使用了,这样他们看的时候,不会太糊涂
from helux.
非常感谢你的建议,文档的确还有很多很多需要改进的确地方,因为是个人维护,最近处于答辩关键时期,所以文档这一块的建设工作就比较慢了,欢迎你或者你的小伙伴加入concent qq群:647642619,有时候issue里反馈比较慢的话直接群里提问也可以,群里会有其他热心用户帮忙解答。
关于ccReducer的使用建议是在脱开实例的地方才使用,然后维护一个有类型的ccReducer暴露出来给全局用,这样非常方便ide补全方法调用(而非直接使用原始的 cc.reducer,这个只适合在console里直接调用):
参加js实例:https://codesandbox.io/s/concent-guide-xvcej?file=/src/components/biz-smart/Menu.js
ts实例:https://codesandbox.io/s/concent-guide-ts-zrxd5?file=/src/components/biz-smart/Menu.tsx
注: ccReducer 维护在 src/base/ccReducer下了
renderKey这些提示其实是因为你还未标注类型所以ide感知不到,例如
https://codesandbox.io/s/concent-guide-xvcej?file=/src/pages/FnVsClass/BetterFnDemo.js:1669-1672
这个文件的50那里,你刻意解开既可以便可查看renderKey等参数说明
强烈建议多看看示例工程的代码组织方式,通过 types/store
集中维护好所有模块的类型,然后在整个项目的任意地方都可以使用这些类型了。
文档这方面肯定会努力完善,欢迎你或者其他小伙伴多多关注concent并点颗小星星,这是作为开源作者能收到的最大精神鼓励,也是持续维护和更新下去的动力。
最后我准备升级下版本,renderKey的注入方式可通过id来标识,当实例上有id属性时,则当前组件的renderKey就设置为id的值,这样可以让用户省去构造ccOption
的麻烦,因为绝大多数场景实例的id通常就是唯一标识符号。
改进前:
<Cell key={id} ccOption={{renderKey:id}} id={id}/>
改进后:
<Cell key={id} id={id}/>
// 组件的setup里取到的renderKey的值就是id
function setup(ctx){
const { renderKey, props, ccUniqueKey } = ctx;
// 如果设置了props里设置了id
renderKey === props.id
// 如果没有设置props.id
renderKey === ccUniqueKey
}
from helux.
已优化,见示例:https://codesandbox.io/s/render-key-dwrx1?file=/src/App.js
id 即可作为renderKey标识
from helux.
我会尽量优先吧高频使用的api逐步补齐到足够友好的程度,感谢建议
from helux.
Related Issues (20)
- 导出 ICtxBase 接口给 ctx 指定后,调用 dispatch 返回类型强制变成了unknown HOT 2
- 有计划抽离concent吗?更加纤细
- 为何版本从2020就停止维护了? HOT 5
- Rebuild the project with Typescript. HOT 1
- reducer中ac.dispatch派发的函数调用,loading插件捕获不到? HOT 2
- 修改既修改私有状态也修改模块状态的问题 HOT 1
- 使用中感到难受疑惑的点 HOT 7
- 更新到2.16.4之后出现了报错 HOT 3
- 文档字段错误 HOT 2
- [交流] 新状态库,求拍砖 HOT 6
- 关于 state 和 moduleState 的疑问 HOT 10
- 实例的watch监听对undefined不生效 HOT 3
- 关于 dispatch 的 callback 问题 HOT 3
- 无法与 Next 12.1.0 一起使用 HOT 4
- 连接的模块无法触发更新!!! HOT 3
- 支持react18并发模式 HOT 4
- 和jotai ,valtio 的对比有吗, 另外readme里的教程用的还是class,有function版本的吗 HOT 4
- 虽然小众 但初步用起来真香 类似vuex存储就行 而setup是惊喜分离了数据逻辑 HOT 6
- [bug] v2.19.12: react Invalid hook call HOT 3
- 【bug】reducer的payload为数组时 数组赋值的同时被展开挂载到根状态上 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from helux.