onlycode.org

javascript
jquery
html
angularjs
css
node.js
ajax
html5
php
json
arrays
google-chrome
dom
regex
reactjs
ecmascript-6
javascript-events

your's history:
react js the most effici...

React.js: the most efficient way to pass a parameter to an event handler without bind() in a component, just only code

reactjs | javascript

edit
this.boundHandleClick = this.handleClick.bind(this, 111);
this.boundHandleClick = () => this.handleClick(111);
return (
  <div className="App">
    <button onClick={this.boundHandleClick}>Click</button>
  </div>
);
this.boundClicks = {};
// ...
if (!this.boundClicks['111']) this.boundClicks['111'] = () => this.handleClick(111);
return (
  <div className="App">
    <button onClick={this.boundClicks['111']}>Click</button>
  </div>
);

29
CertainPerformance, 13.10.2018 04:06




edit
handleClick = () => () => {
    this.setState({ // this works now
      isClicked:true
    });
}
handleClick = (param1, param2, param3) => (event) => {
onClick={this.handleClick(param1,param2,param3)}

27
Bhojendra Rauniyar, 13.10.2018 05:11



edit
class App extends React.Component {
  state = {
    change: ""
  };

  handleChange = e => {
    const { name, value } = e.target;
    this.setState({ [name]: value  })
  };

  render() {
    return (
      <input
        type="text"
        onChange={this.handleChange}
        name="change"
        value={this.state.change}
      />
    );
  }
}

10
Kyaw Siesein, 13.10.2018 04:09

Add your just only code

your name:    



If you need full text click here

Some similar links React.js: the most efficient way to pass a parameter to an event handler without bind() in a component ↓:
How to pass event as argument to an inline event handler in JavaScript?

/ JS bind “paste” event handler to input textbox

How do I pass the this context into an event handler?

React JS onClick event handler



This project is created for those who just need only code, wihout maaaaaaaaaaany words.