Created
November 6, 2021 10:57
-
-
Save UsmanHaider15/b66e98f0c64770ce137bd5fe5037f5a3 to your computer and use it in GitHub Desktop.
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
import React from "react"; | |
export default function IFFISwitch() { | |
const [key, setKey] = React.useState("first"); | |
return ( | |
<div> | |
<div> | |
{(() => { | |
switch (key) { | |
case "first": | |
return "This is First Case"; | |
case "second": | |
return "This is Second Case"; | |
default: | |
return "This is default value"; | |
} | |
})()} | |
</div> | |
<br /> | |
<div> | |
<button onClick={() => setKey("first")}>First</button> | |
<button onClick={() => setKey("second")}>second</button> | |
</div> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment