I'm new to React, and so far I understand that className in React jsx can be a reference to an html class defined in an imported css file. Like className="warning" in the following example, which makes the text display red instead of the default black.
But I'm also seeing, in numerous tutorial examples, elements like <div className="App"> appearing at the top of the render() function. This typically doesn't reference anything in the imported css file, yet it can often be present even if there is no imported css file in the example at all.
Indeed I find that if I replace it with just <div>, the example renders exactly as before. So what do elements like <div className="App"> do, and what are they for?
App.js
import React, { Component } from 'react';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<h1 className="warning">Wakeup World!</h1>
</div>
)
}
}
export default App;
App.css
.warning {
color: red
}