Reactjs 同构中继路由器:无法将数据传递到组件
大家好,你好 我在接力工作时有些打嗝。由于某些原因,没有数据被传递到我的边栏组件。数据在我的Reactjs 同构中继路由器:无法将数据传递到组件,reactjs,router,graphql,relay,isomorphic,Reactjs,Router,Graphql,Relay,Isomorphic,大家好,你好 我在接力工作时有些打嗝。由于某些原因,没有数据被传递到我的边栏组件。数据在我的节点中可用,但无法传递到应该传递的位置 client.js: App.js-常规无状态组件(无中继包装器) 侧边栏道具: 此外,将显示以下错误:RelayContainer:预期将向“侧栏”提供道具“笑话”,但得到“未定义”。如果有意传递一个显式的“null”。(与quote相同) 我不知道怎么了,我需要你的帮助,拜托 问题是不正确的中继查询使用和同构中继路由器中的错误组合:问题是不正确的中继查询使用和同
节点中可用,但无法传递到应该传递的位置
client.js:
App.js-常规无状态组件(无中继包装器)
侧边栏道具:
此外,将显示以下错误:RelayContainer:预期将向“侧栏”提供道具“笑话”,但得到“未定义”。如果有意传递一个显式的“null”。
(与quote
相同)
我不知道怎么了,我需要你的帮助,拜托 问题是不正确的中继查询使用和同构中继路由器中的错误组合:问题是不正确的中继查询使用和同构中继路由器中的错误组合:
match({ routes, history: browserHistory }, (error, redirectLocation, renderProps) => {
if (error) throw error;
IsomorphicRouter.prepareInitialRender(environment, renderProps).then((props) => {
ReactDOM.render(
<Router {...props} />,
root
);
});
});
[{
path: '/',
component: App,
indexRoute: {
getComponents: (nextState, cb) => {
Promise.all([
System.import('./Home/Hero'),
System.import('./Home'),
System.import('../components/Sidebar')
])
.then(modules => cb(null, {
hero: modules[0].default,
content: modules[1].default,
sidebar: modules[2].default
}))
.catch((e) => { throw e; });
},
queries: {
sidebar: {
joke: () => Relay.QL`query Joke { randomJoke }`,
quote: () => Relay.QL`query Quote { randomQuote }`
}
}
}
}];
<div className={s.root}>
{hero}
<main>
<Header />
{content}
{sidebar}
</main>
<Footer />
</div>
...
Relay.createContainer(Sidebar, {
fragments: {
joke: () => Relay.QL`
fragment on Joke {
text
}
`,
quote: () => Relay.QL`
fragment on Quote {
text,
author,
sourceUrl
}
`
}
});
{"history":{},"location":{"pathname":"/","search":"","hash":"","state":null,"action":"POP","key":"aelohd","query":{},"$searchBase":{"search":"","searchBase":""}},"params":{},"route":{"queries":{"sidebar":{}}},"routeParams":{},"routes":[{"path":"/","indexRoute":{"queries":{"sidebar":{}}},"childRoutes":[{"path":"/register","queries":{"content":{}}},{"path":"/publications","queries":{"content":{}}}]},{"queries":{"sidebar":{}}}],"children":null,"relay":{"pendingVariables":null,"route":{"name":"_aggregated___route_1_sidebar_joke___route_1_sidebar_quote","queries":{},"params":{}},"variables":{}}}