Skip to content

The books chapter on React uses pre version 18 syntax? #27

Description

I get a bunch of error messages when running the tests on page 259. I tried to do the following:

import React from "react";
import {App} from "./App.jsx";
import {render} from "react-dom";
import { createRoot } from 'react-dom/client';
import {act} from "react-dom/test-utils"

// @ts-ignore
global.IS_REACT_ACT_ENVIRONMENT = true
const container = document.createElement("div");
let root = createRoot(container)


test('renders the h1 header', () => {
    act(()=> {
      root.render(<App />);
    });
    const header = document.querySelector("h1");
    expect(header.textContent).toBe("Cheesecakes: ")
    
  });

But I get null passed to the header so the test fails.

If you could point me int he right direction that would be awesome.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions