React: Call Function with Parameters in onClick Event

/** * My Function * * @returns {*} Console Log */ myFunction = () => { console.log('myFunction()') }; /** * My Extended Function * * @param {string} name Name * @param {int} age Age * @returns {*} Console Log */ myExtendedFunction = (name, age) => { console.log('myExtendedFunction() -> name: ' + name + ', age: ' + age) }; render() { return( <button onclick={this.myFunction}>Call a Function</button> <button onclick={() => this.myExtendedFunction('Kevin', 19)}>Call a Function with Parameter</button> ) }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.