组件中无state无其他函数 组件本身就是一个函数
import React from "react";import { Input, Button, List } from "antd";const TodoListUI=(props)=>{ return ( <div> <div style={{ margin: "10px" }}> <Input placeholder="Write Somthing" style={{ width: "250px", marginRight: "10px" }} onChange={props.changeInputValue} value={props.inputValue} /> <Button type="primary" onClick={props.clickBtn}> 增加 </Button> </div> <div style={{ margin: "10px", width: "300px" }}> <List bordered dataSource={props.list} renderItem={(item, index) => ( <List.Item onClick={() => { props.deleteItem(index); }} > {item} </List.Item> )} ></List> </div> </div> );}export default TodoListUI;
优点:因为没有其他的属性 ,所以效率比一般组件要高