File tree Expand file tree Collapse file tree 3 files changed +18
-25
lines changed Expand file tree Collapse file tree 3 files changed +18
-25
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 @@ -10,14 +10,9 @@ interface ShowProps<T = boolean> {
1010}
1111
1212const Item = ( props : any ) => {
13- const result =
14- typeof props . children === "function"
15- ? props . children ( props . v , props . i )
16- : props . children ;
17- if ( props . cache ) {
18- props . cache . set ( props . v , result ) ;
19- }
20- return result ;
13+ return typeof props . children === "function"
14+ ? props . children ( props . v , props . i )
15+ : props . children ;
2116} ;
2217
2318export function Show < T = boolean > ( props : ShowProps < T > ) : JSX . Element | null {
@@ -47,7 +42,9 @@ export function For<T>(props: ForProps<T>): JSX.Element | null {
4742
4843 const items = list . map ( ( value , key ) => {
4944 if ( ! cache . has ( value ) ) {
50- return < Item v = { value } i = { key } children = { props . children } cache = { cache } /> ;
45+ const result = < Item v = { value } i = { key } children = { props . children } /> ;
46+ cache . set ( value , result ) ;
47+ return result ;
5148 }
5249 return cache . get ( value ) ;
5350 } ) ;
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,15 +45,11 @@ 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 (
54- < Item
55- v = { value }
56- key = { key }
57- i = { key }
58- children = { props . children }
59- cache = { cache }
60- />
48+ const result = (
49+ < Item v = { value } key = { key } i = { key } children = { props . children } />
6150 ) ;
51+ cache . set ( value , result ) ;
52+ return result ;
6253 }
6354 return cache . get ( value ) ;
6455 } ) ;
You can’t perform that action at this time.
0 commit comments