简体   繁体   中英

react-apollo providing data and mutation to the component

I used to use prevues version of where I could use connect to provide data and mutation methods to component like so:

export default connect({
  mapQueriesToProps,
  mapMutationsToProps,
})(component);

And in each mapQueriesToProps and mapMutationsToProps I could provide many instance for example 2-3 data queries and several mutation methods.

But how can I do it using following pattern in the new version?

export default graphql(data, {
  options: ({ params: { id } }) => ({
    variables: {
      id: Number(id),
    },
  }),
})(component);

You could use compose several times.

Compose all the mutations and all the queries and then compose them in your component.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM