Skip to content

Commit 86d5caa

Browse files
authored
Update mona-high-school-fitness-tracker.md
make sure this is compatible with React 18
1 parent 03f3705 commit 86d5caa

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/mona-high-school-fitness-tracker.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,27 @@ Create the following components
666666

667667
Basic username password authentication is fine
668668

669+
### index.js potential React version issues
670+
671+
The error indicates that the ReactDOM.render function is not available in the version of React you are using. This is because React 18 introduced a new root API for rendering.
672+
673+
To fix this issue, update your src/index.js file to use the new createRoot API provided by React 18. Here's the updated code:
674+
675+
```javascript
676+
import React from 'react';
677+
import ReactDOM from 'react-dom/client'; // Use the new root API
678+
import './index.css';
679+
import App from './App';
680+
import 'bootstrap/dist/css/bootstrap.min.css';
681+
682+
const root = ReactDOM.createRoot(document.getElementById('root')); // Create a root
683+
root.render(
684+
<React.StrictMode>
685+
<App />
686+
</React.StrictMode>
687+
);
688+
```
689+
669690
### Example leaderboard component
670691

671692
Always use the Codespace URL for the API endpoint

0 commit comments

Comments
 (0)