Skip to content

Instantly share code, notes, and snippets.

@UsmanHaider15
Created November 6, 2021 10:57
Show Gist options
  • Save UsmanHaider15/b66e98f0c64770ce137bd5fe5037f5a3 to your computer and use it in GitHub Desktop.
Save UsmanHaider15/b66e98f0c64770ce137bd5fe5037f5a3 to your computer and use it in GitHub Desktop.
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