Relay-Modern尝试更新已经卸载的组件`Relay(Songs)`

时间:2017-10-15 16:20:01

标签: javascript reactjs relay

我使用found-relay进行路由。

如果我不使用片段并在查询中指定名称,那么它可以正常工作。

我做错了什么?

songsContainer.js:

import Songs from './component';

export const query = graphql`
  query songsContainerQuery {
    songs {
      ...songsContainer_songs
    }
  }
`;

export default createFragmentContainer(Songs, graphql`
  fragment songsContainer_songs on Song {
    name
  }`,
);

component.js:

const Songs = ({ songs }) => (
  <Audios
    audios={songs}
  >
    <Song />
  </Audios>
);

export default Songs;

routeConfig.js:

import Songs, { query as songsQuery } from '../../songs/songsContainer';

export default makeRouteConfig(
  <Route path="/">
    <Route Component={PrimaryLayout}>
      <Route exact path="/" Component={Songs} query={songsQuery} />
    </Route>
  </Route>,
);

1 个答案:

答案 0 :(得分:0)

我们需要添加plural指令,否则会出现此错误:

graphql`
  fragment songsContainer_songs on Song @relay(plural: true) {
    name
}`

可怕的错误消息,我会在继电器上为错误的错误消息创建一个问题。