[React Fundamentals] State Basics

Source: Internet
Author: User

State was used for properties on a component that would change, versus the static properties that was passed in. This lesson would introduce you to taking input within your React.

Unlike props, which was meant to being passed into we component as static values or methods, state is a collection of values That's meant to being managed by our component itself.

Import React from ' React '; exportdefaultclass App extends React.component {constructor () {super ();//This is going to give us we have context for this within our component         This. State ={txt:' State ', Count:1}} update (e) { This. SetState ({Txt:e.target.value})} render () {return (            <div> <input type= "text" onchange={ This. Update.bind ( This)}/> <span>hello { This.state.txt}</span> </div>        )    }}

[React Fundamentals] State Basics

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.