Skip to content

Instantly share code, notes, and snippets.

@MarwanShehata
Created April 8, 2022 10:42
Show Gist options
  • Save MarwanShehata/1131fe85c23c07d0275a7e0964dc5d3c to your computer and use it in GitHub Desktop.
Save MarwanShehata/1131fe85c23c07d0275a7e0964dc5d3c to your computer and use it in GitHub Desktop.
import "./App.css";
function App() {
// const handleIt = (e: any, v: number) => {
// console.log(e, v)
// }
const handleIt = (v) => {
return (e) => {
console.log(e, v);
};
};
// use currying to clean your code
return (
<div className="App">
{/* <input onChange={(e)=> handleIt(e, 1)} /> */}
{/* <input onChange={(e)=> handleIt(e, 2)} /> */}
{/* <input onChange={(e)=> handleIt(e, 3)} /> */}
<input onChange={handleIt(1)} />
<input onChange={handleIt(2)} />
<input onChange={handleIt(3)} />
</div>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment