Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DeepMohinman's avatar

'React' must be in scope when using JSX react/react-in-jsx-scope?

I am an Angular Developer and new to React , https://shagle.download This is simple react Component but not working

import react , { Component} from 'react'; import { render } from 'react-dom';

class TechView extends Component {

constructor(props){
   super(props);
   this.state = {
       name:'Gopinath'
   }
}
render(){
    return(
        <span>hello Tech View</span>
    );
}

}

export default TechView; Error : 'React' must be in scope when using JSX react/react-in-jsx-scope

0 likes
1 reply
Sinnbeck's avatar

That looks like an old class syntax for your react component. I suggest using the new syntax which allows using hooks :)

import React, {useState} from 'react' //uppercase R

export default TechView(props) {
    const [name, setName] = useState('Gopinath')

    return (
        <span>hello Tech View</span>
    )
}

https://reactjs.org/docs/hooks-intro.html

Please or to participate in this conversation.