We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8302ccf commit 7765cdcCopy full SHA for 7765cdc
lib/components_guide_web/templates/react_typescript/reducer-patterns.html.md
@@ -1,4 +1,4 @@
1
-# React `useReducer` patterns
+# React Reducer Patterns
2
3
## Menu
4
@@ -27,3 +27,13 @@ tap("edit") // "edit"
27
tap("edit") // null
28
tap(null) // null
29
```
30
+
31
+You can of course condense it to a ternary if you want:
32
33
+```ts
34
+// You can of course shorten it into a ternary if you really want:
35
+const [openMenu, tap] = useReducer(
36
+ (current: Menu, action: Menu) => (action === current) ? null : action,
37
+ null
38
+);
39
+```
0 commit comments