Let’s see how ReactJS works with SharePoint. This is a sample ReactJS example which displays Hello React!! in the Script Editor Web Part.
Open and Edit the page in which you want to add the ReactJS code.
Add Script Editor Web Part and copy below code in that
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<div id="root"></div>
<script type="text/babel">
ReactDOM.render(
<h1>Hello ReactJS!</h1>,
document.getElementById('root')
);
</script>
Below is the output in the WebPart:

You can also go with the below code that will create a separate custom element:
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<div id="root"></div>
<script type="text/babel">
class App extends React.Component {
render() {
return (
<div>
Hello World!!!
</div>
);
}
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
</script>















