react組件複用

class Mybtn extends Component {
    render() {
        return (
           <button>{this.props.title}</button>
        );
    }
}
class App extends Component {
    constructor(props) {
        super(props);
    }
    render() {
        return (
            <div>
                <h2>hello,{this.props.name}</h2>
                <Mybtn title='提交'></Mybtn>
                <Mybtn title='刪除'></Mybtn>
                <Mybtn title='修改'></Mybtn>
                <Mybtn title='添加'></Mybtn>
            </div>
        )
    }
}

export default App;
相關文章
相關標籤/搜索