gpt4 book ai didi

reactjs - Flux 架构中的 Controller View 是什么?

转载 作者:行者123 更新时间:2023-12-03 13:41:19 27 4
gpt4 key购买 nike

我看到 Flux 架构和 React 项目经常提到这个术语。

据我了解,这是一种设计模式,但我在网上找不到很好的描述。

最佳答案

“ Controller View ”的概念一开始确实让我产生了偏差。

我能找到的最好的“定义”就在那里:https://facebook.github.io/flux/docs/todo-list.html#listening-to-changes-with-a-controller-view

We need a React component near the top of our component hierarchy to listen for changes in the store. In a larger app, we would have more of these listening components, perhaps one for every section of the page. In Facebook's Ads Creation Tool, we have many of these controller-like views, each governing a specific section of the UI.

我们的解释是,一旦您拥有一个大的组件层次结构,您就不希望每个组件都监听可能影响它的每个更改。相反,您选择一个顶部/父组件来监听更改,然后通过 props 将更改的值传播到其子组件。这些子项将根据 Prop 更改的需要重新渲染。该顶部组件成为层次结构的“ Controller ”。

关于reactjs - Flux 架构中的 Controller View 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33366161/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com