我是服务器端渲染应用程序,服务器代码看起来像这样
const markup = renderToString(
<StaticRouter context={{a:1}} location={req.url}>
<App d='8' />
</StaticRouter>
)
并在App组件中打印出道具
class App extends Component {
constructor(props){
super(props);
console.log(this)
}
但是输出没有staticContext,它看起来像这样
App {
props: { d: '8' },
context: undefined,
refs: {},
updater:
{ isMounted: [Function: isMounted],
enqueueForceUpdate: [Function: enqueueForceUpdate],
enqueueReplaceState: [Function: enqueueReplaceState],
enqueueSetState: [Function: enqueueSetState] } }
我正在使用react 16.3和react-router-dom 4.3.1,为什么我无法访问staticContext prop?