Created
January 26, 2020 11:04
-
-
Save manojnaidu619/2c8051ed9eb538983eff47578a03446f to your computer and use it in GitHub Desktop.
React functional component(Uses hooks for state management)
This file contains hidden or 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
import React, {useState} from 'react'; | |
const App = props => { | |
const [pstate, sstate] = useState({ | |
name: "Manoj", | |
country: "India" | |
}) | |
const switchNameHandler = () => { | |
sstate({ | |
name: "Arun", | |
country: "Japan" | |
}) | |
} | |
return( | |
<div className="App"> | |
<h1>Hello</h1> | |
<button onClick={switchNameHandler}>Click Here</button> | |
<p>{pstate.name}</p> | |
<p>{pstate.country}</p> | |
<Person name="manoj"/> | |
</div> | |
) | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment