Skip to content

Instantly share code, notes, and snippets.

@calloc134
Created October 19, 2024 08:35
Show Gist options
  • Select an option

  • Save calloc134/48fd096f35492a43f928cf0757297277 to your computer and use it in GitHub Desktop.

Select an option

Save calloc134/48fd096f35492a43f928cf0757297277 to your computer and use it in GitHub Desktop.
bakahook
import { useState } from "react";
import "./App.css";
function App() {
const random = Math.random();
if (random > 0.5) {
const [count1, setCount1] = useState(0);
const [count2, setCount2] = useState(123);
return (
<div>
<h1>If Mode</h1>
<a>count is {count1}</a>
<br />
<a>name is {count2}</a>
<br />
<button onClick={() => setCount1((count) => count + 1)}>count</button>
</div>
);
} else {
const [name, setName] = useState(0);
const [count, setCount] = useState(0);
return (
<div>
<h1> Else Mode</h1>
<a>count is {count}</a>
<br />
<a>name is {name}</a>
<br />
<button onClick={() => setCount((count) => count + 1)}>count</button>
</div>
);
}
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment