JavaScript React ES6 onSubmit() does not work react onsubmit is not a function,react form onsubmit do

I'm currently working on a project using webpack and babel to build a project. I tried so many things as I can think of, but somehow onSubmit or onClick function do not work no matter how I bind those functions. Here is the code snippet of the code. Can anyone think of any possible reason?

Here's the code. I can't (usefully) make it a Stack Snippet because they don't allow form submissions.

export default class CommentForm extends React.Component {
    constructor(props) {
        super(props);
        console.log("constructor");
    }

    onSubmit(e) {
        e.preventDefault();
        console.log("you clicked")

        // 1. Take data from from form
        let commentData = {
             // commentName: this.refs.name.value,
             commentBody: this.refs.content.value
        }

        // 2. Pass data back to App
        this.props.addComment(commentData);

        // 3. Reset the form
        this.refs.commentForm.reset();
    }

    render() {
        return (
          <div className="commentForm">
            <form name="comment" id="comment" onSubmit={this.onSubmit.bind(this)}>
              <textarea className="commentText" ref="content" rows="10" placeholder="Comment"></textarea>
              <button id="submit" type="submit">Add Value</button>
            </form>
          </div>
        );
    }
}
Answer:1

Here is a working fiddle, logging the values to the console. You don't need to use refs and the use of refs should be limited where possible.

Instead of refs, give the form elements a name and use

e.target.content.value

to access the values

https://jsfiddle.net/jq17t7uh/1/

Answer:2

Im really new to JavaScript and I started a new project that consists in a video player and editor. I have this modal Box: <div class="modal" id="myModal"> <div class="modal-header"> ...

Im really new to JavaScript and I started a new project that consists in a video player and editor. I have this modal Box: <div class="modal" id="myModal"> <div class="modal-header"> ...

  1. source from video tag
  2. source video from
  3. find source from video
  4. source video html
  5. source video maker
  6. source video calgary
  7. source video html5
  8. source video editor
  9. source video interview
  10. source video youtube
  11. source video edmonton
  12. source video games
  13. source video 4k
  14. source video finder
  15. source video interview questions
  16. source video download
  17. source video type
  18. source video vlc obs
  19. source video facebook
  20. source video js

#anotherdata=value#iamlookingforthis=226885#id=101&start=1 Given the string above how could I extract "iamlookingforthis=226885" in the string? value of it might change as this is dynamic. So, ...

#anotherdata=value#iamlookingforthis=226885#id=101&start=1 Given the string above how could I extract "iamlookingforthis=226885" in the string? value of it might change as this is dynamic. So, ...

  1. extract specific word from excel cell
  2. extract specific word from text file python
  3. extract specific word from string python
  4. extract specific word from sentence in excel
  5. extract specific word from string excel
  6. extract specific word from string sql
  7. extract specific word from cell
  8. extract specific word from string java
  9. extract specific word from string c#
  10. extract specific word from string javascript
  11. regex extract specific word
  12. extract text after specific word in excel
  13. extract specific pages from word
  14. extract specific pages from word document
  15. extract specific text from word document
  16. extract specific data from word to excel vba
  17. excel formula extract specific word
  18. extract specific text from word document python
  19. extract text after specific word
  20. extract text after specific word python

I am trying to implement a checkbox as a button as described here: https://v4-alpha.getbootstrap.com/components/buttons/#checkbox-and-radio-buttons I am trying to listen to the the change event of ...

I am trying to implement a checkbox as a button as described here: https://v4-alpha.getbootstrap.com/components/buttons/#checkbox-and-radio-buttons I am trying to listen to the the change event of ...

  1. checkbox input style
  2. checkbox input style css
  3. input checkbox style css3
  4. input checkbox style bootstrap
  5. input checkbox style codepen
  6. input checkbox style checked
  7. input checkbox style size
  8. input checkbox style w3schools
  9. input checkbox style color
  10. input checkbox style html
  11. input checkbox style border
  12. change checkbox input style
  13. input type checkbox style
  14. input type checkbox style css
  15. input checkbox focus style
  16. input checkbox css style examples
  17. css change input checkbox style
  18. bootstrap 4 input checkbox style
  19. input checkbox inline style
  20. input checkbox custom style

I am looking at this example from openlayers themselves. You can see the source by clicking on the "kml-layer.js" link at the bottom. The source code when i do this looks like this: var map = new ...

I am looking at this example from openlayers themselves. You can see the source by clicking on the "kml-layer.js" link at the bottom. The source code when i do this looks like this: var map = new ...

  1. openlayers local tiles
  2. openlayers local tiles example
  3. openlayers local map
  4. openlayers local tile server
  5. openlayers local geojson
  6. openlayers local
  7. openlayers local image
  8. openlayers local storage
  9. openlayers local server
  10. openlayers local source
  11. openlayers local kml file
  12. openlayers local install
  13. openlayers local icon
  14. openlayers local osm
  15. openlayers local file