I am newbie in react development and trying to understand how classNames work in react.
This is the react code from my book. I just copied it.
const MOUNT = document.getElementById('root');
class App extends React.Component {
render() {
const klasses = classNames({
box: true, // always apply the box class
alert: this.props.isAlert, // if the prop is set
severity: this.state.onHighAlert, // with state
timed: false // never apply this class
});
return React.createElement(
'div',
{className: klasses},
React.createElement('h1', {}, 'Hello world')
);
}
}
ReactDOM.render(React.createElement(App, {}), MOUNT);
I included script file with this code to html and browser console shows such error.
app.js:4 Uncaught ReferenceError: classNames is not defined
at App.render (app.js:4)
at finishClassComponent (react-dom.js:11320)
at updateClassComponent (react-dom.js:11297)
at beginWork (react-dom.js:11676)
at performUnitOfWork (react-dom.js:13644)
at workLoop (react-dom.js:13753)
at HTMLUnknownElement.callCallback (react-dom.js:1527)
at Object.invokeGuardedCallbackDev (react-dom.js:1566)
at invokeGuardedCallback (react-dom.js:1423)
at performWork (react-dom.js:13871)
what is the problem?