2016-09-27 3 views
1

안녕하세요!isomorphic-relay-router : 구성 요소에 데이터를 전달할 수 없습니다.

나는 릴레이로 작업하는 데 많은 고생을하고 있습니다. 어떤 이유로 든 내 사이드 ​​바 구성 요소에 데이터가 전달되지 않습니다. 데이터는 내 <script id="preloadedData"> 노드에서 사용할 수 있지만이

client.js 어디로 가야에 전달하기 아니에요 :

match({ routes, history: browserHistory }, (error, redirectLocation, renderProps) => { 
    if (error) throw error; 
    IsomorphicRouter.prepareInitialRender(environment, renderProps).then((props) => { 
     ReactDOM.render(
     <Router {...props} />, 
     root 
     ); 
    }); 
}); 

routes.js :

[{ 
    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 }` 
      } 
     } 
    } 
}]; 

을 App.js - 일반 상태 비 저장 구성 요소 (릴레이 래퍼 없음)

,
<div className={s.root}> 
    {hero} 
    <main> 
    <Header /> 
    {content} 
    {sidebar} 
    </main> 
    <Footer /> 
</div> 

Sidebar.js

... 

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":{}}} 

: RelayContainer: Expected prop 'joke' to be supplied to 'Sidebar', but got 'undefined'. Pass an explicit 'null' if this is intentional. (quote에 대한 동일)

내가 더이 무엇이 잘못 됐는지 생각해 보겠습니다. 도와 줘, 제발!

답변

0

문제는 isomorphic-relay-router의 잘못된 릴레이 쿼리 사용과 버그의 조합입니다 : link to the issue

관련 문제