I've created a simple test program in React which displays a piece of text.
import React from 'react';
import componentClass from './components/componentClass';
export default function App () {
return (
<h1>example</h1>
)
}
What I'm trying to do now is take this example text and make it its own separate component. I've created a class component named componentClass where the example text is displayed.
import React, { Component } from 'react';
export default class componentClass extends Component {
render() {
return (
<h1>example</h1>
)
}
}
I'm then rendering this component in App.js.
import React from 'react';
import componentClass from './components/componentClass';
export default function App () {
return (
<componentClass />
)
}
The problem is that nothing is showing up so I'm confused as to why the component isn't being displayed. Below is my index.js file.
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
reportWebVitals();