Skip to content

enable @swc-jotai/react-refresh in [email protected] will cause pages using 'use client' error #21

Open
@seiry

Description

@seiry

reproduce step

  1. init a new next.js repo
  2. install jotai and @swc-jotai/react-refresh
  3. enable @swc-jotai/react-refresh in next.config.js
  4. add a jotai atom in a page with 'use client'
  5. get the error

reproduce repo

https://github.com/seiry/jotai-refresh-use-client/blob/e2f069f9761f35c75d23a9e71f6a13a279275e9a/next.config.js#L6

log

./app/page.tsx
ReactServerComponentsError:

The "use client" directive must be placed before other expressions. Move it to the top of the file to resolve this issue.

   ╭─[/Users/seiry/gitwork/jotai-refresh-use-client/app/page.tsx:1:1]
 1 │ 'use client'
   · ────────────
 2 │ import { atom, useAtom } from 'jotai'
 3 │ 
 4 │ const valueAtom = atom('hello')
   ╰────

Import path:
  ./app/page.tsx

It seems the plugin added some line at the file header.( sorry I'm not a rust master lol

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions