Refs
在一般情况下,props 是父组件与子组件交互的唯一方式-传入新的 props 来重新渲染子组件。
但 Refs 提供了访问在 render 方法中创建的 DOM 节点或 React 元素的方式来实现在典型数据流外强制修改子代。
[link]: https://react.docschina.org/docs/refs-and-the-dom.html
Context
Context(上下文) 为一种在组件间共享值的方法,使得组件可以不必须通过组件树来每个层级地依次传递值。
[link]: https://react.docschina.org/docs/context.html
网友评论