如何将getChildContext与功能组件一起使用

时间:2016-09-08 15:24:47

标签: javascript reactjs react-native ecmascript-6 redux

我想通过功能组件的上下文向树中传递一些道具 这几乎是应用程序的顶部。有没有办法实现这一目标,或者我们应该声明ES6 / createClass反应组件?

由于

2 个答案:

答案 0 :(得分:4)

enter image description here

您无法使用功能组件向儿童传递上下文

答案 1 :(得分:0)

像往常一样定义contextTypes:

import codecs
codecs.open(file_name, 'r', 'utf8')

可以使用小提琴:https://jsfiddle.net/69z2wepo/55601/