Skip to content

useFetcher and fetcher.submit in child component trigger unexpected parent (route) component re-render #13959

Open
@fonzcastellanos

Description

@fonzcastellanos

Reproduction

Go to https://stackblitz.com/~/github.com/fonzcastellanos/react-router-use-fetcher-bug, enter a non-empty string to the "Message" input field, and press the "Submit" button.

Note that StrictMode is disabled.

System Info

System:
    OS: macOS 15.5
    CPU: (14) arm64 Apple M3 Max
    Memory: 1.61 GB / 36.00 GB
    Shell: 5.2.21 - /opt/homebrew/bin/bash
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
  npmPackages:
    @react-router/dev: ^7.5.3 => 7.6.3 
    @react-router/node: ^7.5.3 => 7.6.3 
    @react-router/serve: ^7.5.3 => 7.6.3 
    react-router: ^7.5.3 => 7.6.3 
    vite: ^6.3.3 => 6.3.5

Used Package Manager

npm

Expected Behavior

I expected the Parent route component to not re-render, while the Child component would re-render as a result of calling fetcher.submit, which submits to the /resource resource route that defines only an action.

Actual Behavior

The Parent route component re-rendered unexpectedly. After the handlerSubmit function executed (which calls fetcher.submit), both the Parent and Child components re-rendered.

This is the browser console output.

Image

This is the terminal output from the dev server. "hello world" was the string I entered into the "Message" field.

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions