0

Hot to use Jquery for example in onChange event Example

change(){
$('#selector').trigger('event')..... 
}

render() {
  return <select onChange={this.change}>
             <option value="1>" 1  </option> ..... 

}
2

2 Answers 2

1

Simple answer: don't.

You make a class and then pass the function to the handler. For example:

class Blah extends React.Component {
  handleClick = e => alert('Button click');
  render() {
    return (<button onClick={this.handleClick}>Click me.</button>);
  }
}
Sign up to request clarification or add additional context in comments.

Comments

0

In React you can do this action in two way

  • using react setState
  • use jquery in after component is mounted.

i would prefer to do react way, advantage of using it you are not touching the Dom. Remember everytime you touch the DOM, it is expensive.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.