I have the following code in a basic react app
import React from 'react';
import './App.css';
function genColor() {
return <div style="#000000">Test</div>;
}
function App() {
return (
<div className="App">
{this.genColor()}
</div>
);
}
export default App;
Calling genColor
in the App function, but get
How am I screwing this up?
You've created a global function, but you're calling it as if it's a member of App.
So either move the function to the App class, or remove this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.