2
我有以下組件與查詢和突變,但我的組件不接收數據和突變道具。Apollo:數據/突變道具沒有傳遞到組件
我做錯了什麼或在我的代碼中缺少?查詢雖然得到執行,但它只是沒有傳遞。 this.props.mutate以及this.props.data未定義。
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)))
);
非常感謝您! :) –