Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Created July 11, 2020 17:57
Show Gist options
  • Save sandrabosk/109c69c08ecf9167d35bf7ea8b73ebc1 to your computer and use it in GitHub Desktop.
Save sandrabosk/109c69c08ecf9167d35bf7ea8b73ebc1 to your computer and use it in GitHub Desktop.

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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment