Three places to declare variables or functions like the following code:
import React from 'react';
import ReactDOM from 'react-dom';
const Greeting = props => (
<>Hello, {props.name}</>
);
class Main extends React.Component {
Greeting3 = props => (
<>I'm fine, props.name</>
);
render() {
const Greeting2 = props => (
<>Hi Hi, {props.name}</>
);
return (
<>
<Greeting name="Mary" /><br/>
<Greeting2 name="Ann" /><br/>
<this.Greeting3 name="John" />
</>
);
}
}
ReactDOM.render(<Main />, document.getElementById('root'));
The places of variables Greeting, Greeting2 and Greeting3 are all well declaring and it works. What is the difference for these three places?
Thank you very much.