handleSubmit(e) {
        // stop browser's default behaviour of reloading on form submit
        e.preventDefault();
        axios
            .post("/tasks", {
                name: this.state.name
            })
            .then(response => {
                console.log("from handle submit", response);
                // set state
                this.setState({
                    tasks: [response.data, ...this.state.tasks]
                });
                // then clear the value of textarea
                this.setState({
                    name: ""
                });
            });
    }
// create handleSubmit method right after handleChange method
create handleSubmit method right after handleChange method
create handleSubmit method right after handleChange method
handleSubmit(e) {
        e.preventDefault();
        axios
            .post("/tasks", {
                name: this.state.name
            })
            .then(response => {
                console.log("from handle submit", response);
                this.setState({
                    tasks: [response.data, ...this.state.tasks]
                });
                this.setState({
                    name: ""
                });
            });
    }
handleSubmit ( e ) { e . preventDefault ( ) ; axios . post ( "/tasks" , { name : this . state . name } ) . then ( response => { console . log ( "from handle submit" , response ) ; this . setState ( { tasks : [ response . data , ... this . state . tasks ] } ) ; this . setState ( { name : "" } ) ; } ) ; }
create handleSubmit method right after handleChange method
create handleSubmit method right after handleChange method
// stop browser's default behaviour of reloading on form submit // set state // then clear the value of textarea