Props

Props là cách để truyền dữ liệu từ component cha xuống component con và component con chỉ được đọc và không thể thay đổi.
Ví dụ:

class Welcom extends React.Component {
     render() {
          return <h1>Hello {this.props.name}</h1>
     }
}
const element = <Welcome name="Nguyen Tuong" />;

State

State là một object để lưu trữ dữ liệu. Khi component nhận dữ liệu từ người dùng (nhận giá trị input, checkbox,…) thì những dữ liệu này sẽ được lưu trong state và chỉ có thể cập nhật bởi component định nghĩa state này

Leave a Reply

Your email address will not be published. Required fields are marked *