zoukankan      html  css  js  c++  java
  • [React Fundamentals] State Basics

    State is used for properties on a component that will change, versus static properties that are passed in. This lesson will introduce you to taking input within your React components.

    Unlike props, which are meant to be passed into our component as static values or methods, state is a collection of values that's meant to be managed by our component itself. 

    import React from 'react';
    
    export default class App extends React.Component {
        constructor(){
            super(); //This is going to give us our 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>
            )
        }
    }
  • 相关阅读:
    AutoMapper使用
    C#网络编程
    ASP.NET MVC (Razor)开发
    React的React Native
    WCF搭建
    异步编程
    Async和Await进行异步编程
    C#开发中使用配置文件
    NET转Java
    net 开源组件
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5771544.html
Copyright © 2011-2022 走看看