File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @preact/signals-react " : patch
3+ ---
4+
5+ Ensure the cached and non-cached shape is the same
Original file line number Diff line number Diff line change @@ -11,14 +11,9 @@ interface ShowProps<T = boolean> {
1111
1212const Item = ( props : any ) => {
1313 useSignals ( ) ;
14- const result =
15- typeof props . children === "function"
16- ? props . children ( props . v , props . i )
17- : props . children ;
18- if ( props . cache ) {
19- props . cache . set ( props . v , result ) ;
20- }
21- return result ;
14+ return typeof props . children === "function"
15+ ? props . children ( props . v , props . i )
16+ : props . children ;
2217} ;
2318
2419export function Show < T = boolean > ( props : ShowProps < T > ) : JSX . Element | null {
@@ -50,7 +45,7 @@ export function For<T>(props: ForProps<T>): JSX.Element | null {
5045
5146 const items = list . map ( ( value , key ) => {
5247 if ( ! cache . has ( value ) ) {
53- return (
48+ const result = (
5449 < Item
5550 v = { value }
5651 key = { key }
@@ -59,6 +54,8 @@ export function For<T>(props: ForProps<T>): JSX.Element | null {
5954 cache = { cache }
6055 />
6156 ) ;
57+ cache . set ( value , result ) ;
58+ return result ;
6259 }
6360 return cache . get ( value ) ;
6461 } ) ;
You can’t perform that action at this time.
0 commit comments