我初学者我需要一些关于反应的帮助,我正在从graphql进行API调用,因此突变在后端方面完美运行但我似乎无法在前端工作,我认为这是一个反应问题,如果你知道错误,你能告诉我我在哪里犯了错误,我该如何解决它。基本上我得到了一个" this.props.MutationMakeProduct不是一个函数" 谢谢!
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import {MutationMakeProduct} from '../graphqlstuff/graph';
class AddProductClass extends Component {
constructor(props) {
super(props);
this.state = {
name: '',
comment: ''
};
}
submitForm(e) {
e.preventDefault();
console.log(this.props);
this.props.MutationMakeProduct({
variables: {
name: this.state.name,
comment: this.state.comment
}
});
}
render() {
return (
<form id="add-product" onSubmit={this.submitForm.bind(this)} >
<div className="field">
<label>Product name:</label>
<input type="text" onChange={(e) => this.setState({ name: e.target.value })} />
</div>
<div className="field">
<label>Comment:</label>
<input type="text" onChange={(e) => this.setState({ comment: e.target.value })} />
</div>
<button>+</button>
</form>
);
}
}
export default graphql(MutationMakeProduct)(AddProductClass);