import React, { useState } from'react';functionExample() {// Declare a new state variable, which we'll call "count"const [count,setCount] =useState(0);return ( <div> <p>You clicked {count} times</p> <buttononClick={() =>setCount(count +1)}> Click me </button> </div> );}
次に、pages/index.jsに2行追加
import Head from'next/head'import Example from'../components/example'// add``` <p className="description"> Get started by editing <code>pages/index.js</code> </p> <Example/> // add