Comments (12)
函数组件应为 functional component
from blog.
@pengx17 感谢回复。
之所以用了function component
,是参照了React 官网的叫法。https://reactjs.org/docs/hooks-state.html#hooks-and-function-components
from blog.
确实术语React这边是叫function component 👍 。
内容蛮好的,还没消化完。感觉如果可以对照一下源码就好了
from blog.
//通过闭包的方式,实现队列在不同函数中的共享。前提是每次用的dispatch函数是同一个
const dispatch = dispatchAction.bind(null, queue);
return [hook.memoizedState, dispatch]
这里是不是还要进行一次赋值 queue.dispatch = dispatch ?
因为我在后面看到有直接用 queue.dispatch 但是没有赋值。
from blog.
//通过闭包的方式,实现队列在不同函数中的共享。前提是每次用的dispatch函数是同一个
const dispatch = dispatchAction.bind(null, queue);
return [hook.memoizedState, dispatch]这里是不是还要进行一次赋值 queue.dispatch = dispatch ?
因为我在后面看到有直接用 queue.dispatch 但是没有赋值。
是的,源码这块是有的,的确忽略了。
虽然是伪代码,但你说的这句还是应该加上的,感谢反馈
from blog.
确实术语React这边是叫function component 👍 。
内容蛮好的,还没消化完。感觉如果可以对照一下源码就好了
我基本上是把源码里的核心代码摘出来了,这样比较简单易读。
源码加了太多fiber的逻辑,过于晦涩容易让人望而却步
from blog.
值得读一遍以上的好文。
from blog.
好文,理解Hooks看这篇够了
from blog.
很棒的文章,配合Dan Abramov的这篇文章一起食用,效果好极了
from blog.
这里岂不是违反了hooks的规则,在条件语句中使用了hooks,导致hooks的顺序错乱?
from blog.
规则只说定义不能在条件语句里定义,并没有说使用有此限制
from blog.
from blog.
Related Issues (7)
- babel6默认添加use strict引发的问题和解决方案 HOT 12
- reselect源码分析和最佳实践思考
- 搜狗商业前端工程化蜕变之路 HOT 6
- 架构一个复杂前端系统需要关注哪些点 HOT 2
- 开发一个高质量的前端组件,这些姿势一定要知道 HOT 3
- 研发工程化新玩法:云+WebIDE HOT 2
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 blog.