javascript - React: onClick on button not working -


for past hour, have been trying work. onclick on of buttons not working @ all… doing wrong?

const react = require('react');  class questionnaire extends react.component { constructor (props) {     super(props);     this.state = { selectedsection: 0 }; }  selectsection (e) {     console.log(e); }  render () {     return (         <div>             <div classname='btn-group mr-2' role='group'>                 <button classname='btn btn-primary' onclick={this.selectsection}>a</button>                 <button classname='btn btn-secondary' onclick={this.selectsection}>b</button>                 <button classname='btn btn-secondary' onclick={this.selectsection}>c</button>                 <button classname='btn btn-secondary' onclick={this.selectsection}>d</button>           </div>         </div>     ); } }   module.exports = questionnaire; 

i should mention using express-react-views

try this

    const react = require('react');      class questionnaire extends react.component {     constructor (props) {         super(props);         this.state = { selectedsection: 0 };     }      selectsection = function(e){     console.log(e);   }      render () {         return (             <div>                 <div classname='btn-group mr-2' role='group'>                     <button classname='btn btn-primary' onclick={this.selectsection}>a</button>                     <button classname='btn btn-secondary' onclick={this.selectsection}>b</button>                     <button classname='btn btn-secondary' onclick={this.selectsection}>c</button>                     <button classname='btn btn-secondary' onclick={this.selectsection}>d</button>               </div>             </div>         );     }     } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -