File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,7 @@ export function variantFactory(context: Context) {
3838
3939 // Shortcut for Store<boolean>
4040 if ( 'if' in config ) {
41- $case = config . if . map ( ( value ) : Variant => ( value ? 'then' : 'else' ) as Variant ) ;
42-
41+ $case = config . if as any ;
4342 cases = {
4443 then : config . then ,
4544 else : config . else ,
@@ -54,7 +53,10 @@ export function variantFactory(context: Context) {
5453 }
5554
5655 function View ( props : Props ) {
57- const nameOfCase = context . useUnit ( $case , config . useUnitConfig ) ;
56+ const nameOfCaseRaw = context . useUnit ( $case , config . useUnitConfig ) ;
57+ const nameOfCase = (
58+ 'if' in config ? ifToVariant ( nameOfCaseRaw as any ) : nameOfCaseRaw
59+ ) as Variant ;
5860 const Component = cases [ nameOfCase ] ?? def ;
5961
6062 return React . createElement ( Component as any , props as any ) ;
@@ -70,3 +72,7 @@ export function variantFactory(context: Context) {
7072 } ) as unknown as ( p : Props ) => React . ReactNode ;
7173 } ;
7274}
75+
76+ function ifToVariant ( value : boolean ) : 'then' | 'else' {
77+ return value ? 'then' : 'else' ;
78+ }
You can’t perform that action at this time.
0 commit comments