Do you know what is the correct way of building this project with react?
I can only pass 12 tests and I don’t understand what is wrong anymore. If I could find a good example I could understand better.
Can you share with us the link to the project, the tests that are not passing and then all of your code you currently have. Is your code just in the challenge editor or are you using codepen by chance? When you reply to a comment you can use the format button which looks like </> and paste all your code between the lines it gives you.
We would need all three to be better able to help you, and see whats going on
Switching to the old render method makes it pass 15/16 (React 18 issue with the test)
ReactDOM.render(<App />, document.getElementById('root'))
For the last test
The sequence “5 * - + 5” = should produce an output of “10” : expected ‘-25’ to equal ‘10’
That fails when inputting it manually as well.
1 Like
react_dom_client__WEBPACK_IMPORTED_MODULE_1__.render is not a function
I pasted the code and got this error.
You need to change the import as well.
index.jsx
import React from 'react'
// import ReactDOM from 'react-dom/client'
import ReactDOM from 'react-dom'
import App from './App'
// ReactDOM.createRoot(document.getElementById('root')).render(
// <App />
// )
ReactDOM.render(<App />, document.getElementById('root'))
1 Like
I don’t know how to thank you I was lost at this point and you really saved me. My main problem is solved but I wonder how render method effects the tests is it because of my solution and how could I wrote this code clean?
You can look at the issue we still have open.
opened 05:23PM - 11 May 22 UTC
type: bug
help wanted
scope: curriculum
status: PR in works
Update: In an attempt to fix the issue with React 18 we have implemented delays … to button clicks performed by the tests and before checking the DOM content. This isn't guaranteed to fix the issue for all projects. If you want to make sure your project is not failing because of React 18 start by using the old render method and if that doesn't help downgrade to React 17. Another thing that can help is using the [flushSync](https://reactjs.org/docs/react-dom.html#flushsync) function, but that is really just a last resort type fix.
If your project still fails with React 17 it is likely not an issue with the tests.
---
Code that is passing using React 17 is failing with React 18.
It seems to be an issue with the new batch rendering and our tests. At this time, I'm not sure what the best solution is. I haven't really looked into it much.
### Affected Page
* JavaScript Calculator ✅ (the example project is passing but we may have to use a longer delay)
* [PR](https://github.com/freeCodeCamp/testable-projects-fcc/pull/1454)
* 25 + 5 Clock ✅ (may still fail using React 18 and hooks)
* [PR](https://github.com/freeCodeCamp/testable-projects-fcc/pull/1485)
* Drum Machine ✅
* [PR](https://github.com/freeCodeCamp/testable-projects-fcc/pull/1452)
Tests: https://github.com/freeCodeCamp/testable-projects-fcc/blob/main/src/project-tests/
### Additional context
Forum threads:
https://forum.freecodecamp.org/t/drum-machine-test-7-is-failing/507800/
https://forum.freecodecamp.org/t/stuck-on-drum-machine-test-7/508120/
https://forum.freecodecamp.org/t/25-5-clock-pomodoro-timer-not-passing-test-12-decrease-break-time/504446/12
https://forum.freecodecamp.org/t/my-tests-don-t-make-sense-in-my-25-5-clock/504936
It doesn’t have anything to do with your code, it has to do with changes React made.
1 Like