【发布时间】:2019-08-15 02:41:16
【问题描述】:
以下是我的查询:
import React from 'react';
import getProducts from '../queries/getProduct';
import { Query } from "react-apollo";
export const Product = () => {
const proId = {
"productId": "95eb601f2d13"
}
return (
<Query query={getProducts} variables={proId}>
{({ loading, error, data }) => {
if (loading) return "Loading...";
if (error) return `Error! ${error.message}`;
return (
<div>
{data.map(entry => entry)}
</div>
);
}}
</Query>
);
};
export default Product;
我现在需要将接收到的数据存储在 React 或 Redux(无论哪个是理想的)中,以便我可以在 1/2 组件中访问该数据。如何存储数据而不是像上面那样渲染它?
根据这些数据,我正在渲染 90% 的组件。
【问题讨论】:
标签: reactjs redux react-apollo apollo-client graphql-js