阿波罗:数据/突变道具没有传递给组件
Apollo: data / mutation prop not passed to component
我有一个查询和一个突变的组件,但是我的组件没有接收到数据和突变道具。
我做错了什么或遗漏在我的代码?查询确实执行了,只是没有传递下去。This.props.mutate和this.props.data都是undefined
class ResetConfirm extends React.Component {
static propTypes = {
intl: intlShape.isRequired,
token: React.PropTypes.string,
data: React.PropTypes.shape({
loading: React.PropTypes.bool.isRequired,
checkToken: React.PropTypes.array,
}).isRequired,
mutate: React.PropTypes.func.isRequired,
}
submitForm = (model) => {
this.setState({
loading: true,
});
this.props.mutate({ variables: { password: model.password, token: this.props.token } })
.then(({ data }) => {
// redirect
}).catch((error) => {
console.log('there was an error sending the query', error);
});
}
render() {
//render jsx
}
}
const CheckTokenQuery = gql`
query CheckToken($token: String!) {
checkToken(token: $token) {
response
}
}
`;
const SetNewPasswordMutation = gql`
mutation SetNewPasswordMutation($password: String!, $token: String!) {
resetPassword(password: $password, token: $token) {
response
}
}
`;
export default graphql(SetNewPasswordMutation, { name: SetNewPasswordMutation })(
graphql(CheckTokenQuery, { name: CheckTokenQuery, forceFetch: true })(injectIntl(connect(ResetConfirm)))
);
您已经使用name
来命名突变道具SetNewPasswordMutation
。
this.props.SetNewPasswordMutation(
{ variables: { password: model.password, token: this.props.token } })
相关文章:
- React Native通过Navigator将用户输入数据传递到选项卡栏IOS中的组件
- React-将jSON数据传递给子组件的子组件
- 如何在ReactJs中渲染子组件时重新加载子组件的数据
- 在reactjs组件中预加载数据
- 具有大型数据集的组件仅在 IE11/Edge 上运行缓慢
- 使用数据数组创建多个类似组件
- ReactJS - 输入组件数据传递
- 反应:从父组件获取子组件数据
- Mithril - 在子组件修改父组件数据后重新排序子组件数组
- 反应多页,组件数据传递
- 如何在组件外部访问v-if中的子组件数据
- 聚合物网络组件数据绑定一个js对象/数组
- Vue,js Vue -router 2组件数据没有更新
- 访问自定义组件数据/方法
- 从web-api在每个页面上生成组件数据
- 从Vue组件数据计算函数
- React组件,在父组件中验证子组件数据
- 如何在Vue.js中现有的基础上创建新的组件数据
- React.js:在添加时重新渲染组件数据
- JQuery在加载react js组件数据时触发两次滚动