最近在研究ANT DESIGN PRO的源码,发现他们代码中有使用childContextTypes 和 getChildContext,而react官网上,如果你希望使用应用程序更加稳定,就不要使用上下文(context)。这只是一个实验性的 API ,并且可能在未来的 React 版本中移除。请问下为什么?还是理解的不对?
以下为示例代码
static childContextTypes = {
location: PropTypes.object,
}
getChildContext() {
const { location } = this.props;
return { location };
}
理解是对的。 但是