Skip to content

Call all functions twice in StrictMode #18426

@eps1lon

Description

@eps1lon

React version: 16.3-16.13

Steps To Reproduce

  1. Render function component with side-effects and without hooks in StrictMode
  2. Component only renders once

Link to code example: https://codesandbox.io/s/strictmode-w-and-wo-hooks-vgxvh

The current behavior

StrictMode only renders function components with hooks twice following #15074 (comment)

The expected behavior

I think making the distinction between components with and without hooks causes more confusion than it helps. Especially since the docs do not mention this. I amended past efforts to improve the StrictMode docs but since this has been ignored I'm not sure this helps. I would also work on making the behavior consistent across all function component types if this is possible.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions