Skip to content

client side forms / redirect fail, dev mode errors #263

Description

@aheissenberger

Describe the bug

A form defined in a "use client"; component using an form action to send the data to the server.

  1. import { useActionState } from "@lazarv/react-server/router"; cannot be used - see examples/file-router/pages/forms/components/form-rs.tsxx
  2. using import { useActionState } from "react"; works (examples/file-router/pages/forms/components/form.tsx) but there are the following errors:

A) DEV Mode: Hydration Errors are a side effect of using redirect("/form")

 [react-server] (browser) You are mounting a new %s component when a previous one has not first unmounted. It is an error to render more than one %s component at a time and attributes and children of these components will likely fail in unpredictable ways. Please only render a single instance of <%s> and if you need to mount a new one, ensure any previous ones have unmounted first.

B) the redirect("/forms") or reload("/forms") in the createOrUpdateNote() function is not redirecting to the list view (examples/file-router/pages/forms/actions.ts)

Note: in my real world app a form even without the notation "use client"; and all parent component are not client components will send the form data as rsc stream from the browser and causes the same problems with redirect as when form is a "use client"; component.

Reproduction

https://github.com/aheissenberger/react-server/tree/example_contacts/examples/file-router/pages/forms

Steps to reproduce

See example app in repository

System Info

System:
    OS: macOS 15.7.1
    CPU: (12) arm64 Apple M4 Pro
    Memory: 469.05 MB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.10.0 - /opt/homebrew/bin/node
    npm: 11.6.0 - /opt/homebrew/bin/npm
    pnpm: 9.15.5 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 141.0.7390.123
  npmPackages:
    @lazarv/react-server: workspace:^ => 0.0.0 
    react: 0.0.0-experimental-ead92181-20251010 => 0.0.0-experimental-ead92181-20251010

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions