Last active
May 29, 2023 15:20
-
-
Save dineshdeveloper1/87a109ccab73ed687260b3371765aa74 to your computer and use it in GitHub Desktop.
React Stateless Functional Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//stateless functional Component ========================================================================================= | |
//without arrow function ************* | |
function Hello(props){ | |
return ( | |
<> | |
<h1>Hello, {props.name}</h1> | |
</> | |
) | |
}; | |
export default Hello; | |
//with arrow function **************** | |
const Hello = (props) => ( | |
<> | |
<h1>Hello, {props.name}</h1> | |
</> | |
); | |
export default Hello; | |
// function export within function *************** | |
export const Hello = (props) => ( | |
<div> | |
<h1>Hello, {props.name}</h1> | |
</div> | |
); | |
import {Hello} from './Hello //import component with in {} | |
// example *************************************************** | |
function Hello(props){ | |
return ( | |
<> | |
<h1>Hello, {props.name}, {props.location}</h1> | |
</> | |
) | |
}; | |
export default Hello; | |
<Tool name="Sunday School" location="Bangalore"/> | |
// ========================================================================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment