0

I cannot figure out what is I'm making wrong. Also I had read a several questions on the SOF, but any of them is do not suits me.

I have a stack of errors:

Line 3: 'React' must be in scope when using JSX react/react-in-jsx-scope
Line 4: 'React' must be in scope when using JSX react/react-in-jsx-scope
Line 5: 'React' must be in scope when using JSX react/react-in-jsx-scope
Line 9: 'ReactDOM' is not defined no-undef

function tick() {
  const element = (
    <div>
      <h1>Hello, world!</h1>
      <h2>It is {new Date().toLocaleTimeString()}.</h2>
    </div>
  );
 
  ReactDOM.render(element, document.getElementById('root'));
}

setInterval(tick, 1000);
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
Sviat Kuzhelev
  • 1,758
  • 10
  • 28
  • Does this answer your question? ['React' must be in scope when using JSX react/react-in-jsx-scope?](https://stackoverflow.com/questions/42640636/react-must-be-in-scope-when-using-jsx-react-react-in-jsx-scope) – Henry Woody Oct 24 '22 at 21:19

1 Answers1

5

Add

import React from 'react'
import ReactDOM from 'react-dom'

in the top of the file.

Arber Sylejmani
  • 2,078
  • 1
  • 16
  • 20