- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在应用程序中使用 GraphQL + Relay,发现自己用 createFragmentContainer
包装了几乎所有组件,包括 DOM 层次结构中非常低的组件(通常是功能组件)。
这是使用片段的正确方法吗?我想知道何时将组件包装在片段容器中的准则是什么?当一个组件只需要一个字段并且我可以通过 props 从父级传递该数据时,包装该组件似乎是多余的。
我正在使用 Relay,但我认为这些概念也与 Apollo 类似。
最佳答案
这是我在 Relay 团队工作的同事 Jan Kassens 的回答:
If splitting out components makes sense to you, you should go for it. I find smaller modules generally help making code more understandable. Now, a Button component probably doesn't have to have a fragment attached to it, but if it's a "Like Page" button with a mutation and maybe label specific to the page, I think it makes total sense to make that it's own fragment container.
As with so many things in engineering, there's probably trade offs in splitting out too much, but we've spent a lot of thought on making fragment containers as lightweight and efficient as we can so you shouldn't think too hard about introducing overhead.
关于reactjs - Relay/Apollo 片段应该有多细粒度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53074038/
我有 2 个事实表,每个表都有一个度量组,生产和生产订单。生产具有较低粒度的生产信息(在组件级别)生产订单具有较高级别的信息(具有抬头数量等的订单级别)。 我在 productionorderid 的
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 9年前关闭。 Improve this q
我第一次尝试了解 Akka/Actors,并且对每个 Actor 职责的粒度有点困惑。 在我的应用程序中,有可以使用 WidgetRegistrar 注册/取消注册的 Widget。要向 Regist
我们一直在使用 MVP 模式和 Winforms,并取得了相当大的成功。然而,关于 MVP 总是弹出一个问题: 对于演示者来说,什么是好的粒度? 我的意思是:对于 Winforms,细粒度通常适用于用
我通常使用 git add -p 添加更改,而且很多时候有几个代码块的大块头,由空行分隔。 但是,git 不会进一步拆分 大块头,我不得不求助于手动编辑。 如何增加 hunk 的粒度,以便每个代码块都
例如,我看到 dumps.wikimedia.org/other/pagecounts-raw/,但那里没有特定国家/地区的数据... 最佳答案 据我所知,没有。出于明显的隐私原因,发布的页面查看统计
JavaScript 的源映射似乎通常不比 token 粒度更精细。 例如,identity-map uses token granularity . 我知道我看过其他例子,但不记得在哪里。 为什么我
我有这些目录: ./Tools ./ook/Tools. 我在 setup.cfg 中的 py.test 的 norecursedirs 选项中添加了 Tools。正如预期的那样,当 py.test
我正在使用这个 Accelerometer graph来自 Apple 并尝试转换他们的 G-force 代码以计算 +/- 128。 下图显示标签中的 x、y、z 值与图表上的输出不匹配:(请注意,
此问题围绕 Android 应用程序的架构展开。 在使用 LifeCycle 组件 ViewModel 时,最好是每个 fragment 一个 ViewModel 还是订阅 fragment 的父 A
我是一名优秀的程序员,十分优秀!