You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's check out a slightly different example to see how memoisation effects your application.
67
+
The options parameter is used to pass options directly to the hotkeys package. Check out the [hotkeys docs](https://github.com/jaywcjlove/hotkeys/#option)
68
+
for an overview.
83
69
84
-
```jsx
85
-
constAddToBankComponent= () => {
86
-
const [amount, setAmount] =useState(0);
70
+
### Parameters
71
+
*`filter: (event: KeyboardEvent): boolean` is used to enable hotkeys inside input elements. Check out [hotkeys docs](https://github.com/jaywcjlove/hotkeys/#filter) for usage
72
+
*`splitKey: string` is used to change the splitting character inside the keys argument. Default is `+`, but if you want
73
+
to listen to the `+` character, you can set `splitKey` to i.e. `-` and listen for `ctrl-+`
74
+
*`keyup: boolean` Determine if you want to listen on the keyup event
75
+
*`keydown: boolean` Determine if want to listen on the keydown event
87
76
88
-
// Don't use this in production, won't work as expected.
89
-
useHotkeys('n', () =>setAmount(amount +100), []);
77
+
## Memoisation
90
78
91
-
return (
92
-
<div>
93
-
Add {Math.abs(amount)} dollars to my bank account.
94
-
</div>
95
-
);
96
-
};
97
-
```
79
+
Let's check out a slightly different example to see how memoisation effects your application.
98
80
99
81
<Playground>
100
82
{() => {
@@ -120,24 +102,10 @@ So our logic flow got stuck, tis not what we wanted.
120
102
To fix this there are two approaches when using values that are retrieved by `useState`. You could define a dependency array as
0 commit comments