下面这段话提到了柯里化:
引用自《React 设计思想》:https://github.com/react-guid...
连续性(Continuations)
不幸的是,自从 UI 中有太多的列表,明确的管理就需要大量的重复性样板代码。我们可以通过推迟一些函数的执行,进而把一些模板移出业务逻辑。比如,使用“柯里化”(JavaScript 中的 bind)。然后我们可以从核心的函数外面传递 state,这样就没有样板代码了。
下面这样并没有减少样板代码,但至少把它从关键业务逻辑中剥离。
function FancyUserList(users) { return FancyBox(
UserList.bind(null, users)
);
}const box = FancyUserList(data.users);const resolvedChildren = box.children(likesPerUser, updateUserLikes);const resolvedBox = {
...box,
children: resolvedChildren
};问题:
感觉没理解清楚柯里化,请大佬结合上面的示例帮解释一下,谢谢。
Cats萌萌
精慕HU
随时随地看视频慕课网APP