how to define function in react functional component code example
Example 1: functional component react
function Welcome(props) {
return Hello, {props.name}
;
}
function App() {
return (
);
}
ReactDOM.render(
,
document.getElementById('root')
);
Example 2: create functional component react
import React from 'react'; const App = () => { const greeting = 'Hello Function Component!'; return ;}; const Headline = ({ value }) => {value}
; export default App;
Example 3: functional components react
function Comment(props) {
return (
{props.author.name}
{props.text}
{formatDate(props.date)}
);
}
Example 4: react function component
function Welcome(props) {
return Hello, {props.name}
;
}