Spaces:
Runtime error
Runtime error
File size: 432 Bytes
d757506 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import { useState } from "react";
import { createModel } from "hox";
function useCounter() {
const [count, setCount] = useState(0);
const decrement = (num?:number) => setCount(typeof num !== 'number' ? count - 1 : count - num);
const increment = (num?:number) => setCount(typeof num !== 'number' ? count + 1 : count + num);
return {
count,
decrement,
increment
};
}
export default createModel(useCounter); |