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
<SwitchCase.Switchfallback={<pstyle={{color: "darkorange", width: 230}}>Counter value unsetted.</p>}>
20
+
<SwitchCase.Casewhen={indexCounter===0}>
21
+
<pstyle={{color: "darkturquoise", width: 230, fontWeight: 800}}>Counter value is 1.</p>
22
+
</SwitchCase.Case>
23
+
<SwitchCase.Casewhen={indexCounter===1}>
24
+
<pstyle={{color: "darkkhaki", width: 230, fontWeight: 800}}>Counter value is 2.</p>
25
+
</SwitchCase.Case>
26
+
<SwitchCase.Casewhen={indexCounter===2}>
27
+
<pstyle={{color: "darkcyan", width: 230, fontWeight: 800}}>Counter value is 3.</p>
28
+
</SwitchCase.Case>
29
+
</SwitchCase.Switch>
30
+
</div>);
31
+
}
32
+
```
33
+
34
+
> The component has an array of numbers and a variable state number used like index of array. Every 2 seconds index changes value. It uses __SwitchCase__ component to render different p element with a text indicating the value of array with the current index.
The component has an array of numbers and a variable state number used like index of array. Every 2 seconds index changes value. It uses __SwitchCase__ component to render different p element with a text indicating the value of array with the current index.
Copy file name to clipboardExpand all lines: packages/react-tools/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,13 +147,13 @@
147
147
- [x] removePropertiesFromArrayObjects
148
148
149
149
-__COMPONENT__
150
-
- [] Show component to render or not a component by a condition. Props: when, fallback, keyed. Keyed is a boolean and needs to avoid rerenders children when it is a function.
151
-
- [ ] Switch and Match components with fallback and when props
150
+
- [x] Show
151
+
- [x] SwitchCase
152
152
- [ ] For/Each: A referentially keyed loop with efficient updating of only changed items. The callback takes the current item as the first argument (ref https://javascript.plainenglish.io/react-each-and-of-pattern-b00aa4305089)
153
153
- [ ] Index: Non-keyed list iteration (rendered nodes are keyed to an array index). This is useful when there is no conceptual key, like if the data consists of primitives and it is the index that is fixed rather than the value.
154
154
- [ ] RestrictedRoute (maybe)
155
155
- [ ] ErrorBoundary (?? error event listener)
156
-
- [ ] LazyComponent: Async component loading by path and fallback for suspense
* **`Show`**: Generic component used to conditional render part of the view: it renders _children_ when the _when_ prop is truthy, otherwise the _fallback_ prop, if it is present, or null. [See demo](https://nDriaDev.io/react-tools/#/components/Show)
0 commit comments