npm init next-app nextjs-blog --example "https://github.com/zeit/next-learn-starter/tree/master/learn-starter"
cd nextjs-blog
npm run dev
アクセス
これで動くものができたので、react hookを試す
現在のdirectoryはnextjs-blogだと思う
mkdir components
touch components/example.js
おきにいりのエディタでexample.jsを編集します
import React, { useState } from 'react';
function Example() {
// Declare a new state variable, which we'll call "count"
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => 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