React Hooks环境搭建

559 阅读1分钟

使用create-react-app创建项目

在你想要建立项目的目录里 React_Hooks_Demo

create-react-app XMan

import React, { useState } from 'react';
function Count(){
    const [ count , setCount ] = useState(0);
    return (
        <div>
            <p>You clicked {count} times</p>
            <button onClick={()=>{setCount(count+1)}}>click me</button>
        </div>
    )
}
export default Count;

大功告成。