Workaround for event cannot be associated in the variable map in the render function in react

Source: Internet
Author: User

Workaround for event cannot be associated in the variable map in the render function in react

As shown in the code below, the checkbox for input can display 3 normally, but cannot be associated with HandleChange. Because the code does not display properly, I use the picture










var Input = reactbootstrap.input;
var testcom = React.createclass ({
Getinitialstate:function () {
return {value: ' hello! ',
value2: ' Nihao2 '
};
},
Handlechange:function (event) {
var debug = 1;
Console.log (event);
Console.log (Event.target);
Console.log (event.target.checked);
},
Render:function () {
var sortedprocessarray = [' Alice ', ' Emily ', ' Kate '];
Return (


{
Sortedprocessarray.map (function (item) {
return;
})
}

);
}
});

  React.render(<TestCom/>, document.body);</script>



Workaround, do not return at the time of map. Instead, save the result of the map to a variable and return the variable. That's it.









Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Workaround for event cannot be associated in the variable map in the render function in react

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.