Skip to content

Mismatch between rendered state and logged state #11417

@sQVe

Description

@sQVe

Describe the bug

👋🏼

I noted today that I was getting mismatches between the logged state and the rendered state in a very simple react application. I'm probably missing something but I'm at my wits end.

This is only an issue when running the development server. Running the built application does not have this issue.

Did you try recovering your dependencies?

1.22.11

Environment

Environment Info:

  current version of create-react-app: 4.0.3
  running from /home/sqve/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

  System:
    OS: Linux 5.13 Arch Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
  Binaries:
    Node: 14.17.6 - ~/.local/share/nvm/versions/node/v14.17.6/bin/node
    Yarn: 1.22.11 - ~/.local/share/nvm/versions/node/v14.17.6/bin/yarn
    npm: 7.22.0 - ~/.local/share/nvm/versions/node/v14.17.6/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    react: ^17.0.2 => 17.0.2
    react-dom: ^17.0.2 => 17.0.2
    react-scripts: 4.0.3 => 4.0.3
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  1. Run npx create-react-app state-mismatch.
  2. Change the default App into:
import { useState } from "react";const getRandomString = () => Math.round(Math.random()).toString();export  function App() {
  const [state, setState] = useState([getRandomString()]);console.log(state);return <div className="App">{state.map((x) => x)}</div>;
}export default App
  1. Run yarn run start and refresh until there is a mismatch.

Expected behavior

The state should always be the same.

Actual behavior

There's a mismatch between what the console outputs and what is rendered.
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions