Closed dan-mcdonald closed 1 year ago
Next.js components are server components by default, which means they cannot directly use hooks like useState
or useEffect
. See Server Components.
To resolve that, you need to convert the component into a client component. To do this, you can add the "use client"
directive at the beginning of the file. like so:
'use client'
import { useState } from 'react'
export default function Square({ value, onSquareClick }) {
// Your component code here
}
Yeah, what @A7med3bdulBaset said.
Steps to repro:
create-next-app
per the first recommended option in the installation guideapp/page.tsx
(and sample CSS intoapp/globals.css
)Expected result: A playable game of Tic Tac Toe
Actual result:
(I hope this isn't a dupe. I tried to do my due diligence searching the issues first. This is related to #6079. I'm hoping that you will find this issue to be more actionable in one way or another.)
Applying the suggested fix does get past the issue.