Create a new component ProductCreate
and have its initial state as shown below. Create a form and corresponding methods to handle input changes as well as form submission. You can display a newly created product on the DOM or alert it, as we did in the previous example.
// ProductCreate/index.js
import React from 'react';
class ProductCreate extends React.Component {
// the initial state
state = {
name: '',
price: '',
inStock: false
};
handleInputChange = event => {
/* your code here */
};
handleFormSubmission = event => {
/* your code here */
};
render() {
return <div></div>;
}
}
export default ProductCreate;