-
Notifications
You must be signed in to change notification settings - Fork 22
fix: make styled mapping optional #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||
| /* eslint-disable */ | ||||||
| import { useContext, useState } from "react"; | ||||||
| import { useContext, useState, type ComponentType } from "react"; | ||||||
| import { Appearance } from "react-native"; | ||||||
|
|
||||||
| import type { StyleDescriptor } from "react-native-css/compiler"; | ||||||
|
|
@@ -30,6 +30,10 @@ export { | |||||
|
|
||||||
| export { useNativeCss }; | ||||||
|
|
||||||
| const defaultMapping: StyledConfiguration<ComponentType<{ style: unknown }>> = { | ||||||
| className: "style", | ||||||
| }; | ||||||
|
|
||||||
| /** | ||||||
| * Generates a new Higher-Order component the wraps the base component and applies the styles. | ||||||
| * This is added to the `interopComponents` map so that it can be used in the `wrapJSX` function | ||||||
|
|
@@ -41,7 +45,7 @@ export const styled = < | |||||
| const M extends StyledConfiguration<C>, | ||||||
| >( | ||||||
| baseComponent: C, | ||||||
| mapping: M, | ||||||
| mapping: M = defaultMapping as M, | ||||||
|
||||||
| mapping: M = defaultMapping as M, | |
| mapping: M, |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { | |||||
| createElement, | ||||||
| useMemo, | ||||||
| type ComponentPropsWithRef, | ||||||
| type ComponentType, | ||||||
| type PropsWithChildren, | ||||||
| } from "react"; | ||||||
| import { Appearance } from "react-native"; | ||||||
|
|
@@ -17,12 +18,16 @@ import type { | |||||
| import type { ReactComponent } from "../runtime.types"; | ||||||
| import { assignStyle } from "./assign-style"; | ||||||
|
|
||||||
| const defaultMapping: StyledConfiguration<ComponentType<{ style: unknown }>> = { | ||||||
| className: "style", | ||||||
| }; | ||||||
|
Comment on lines
+21
to
+23
|
||||||
|
|
||||||
| export const styled = < | ||||||
| const C extends ReactComponent, | ||||||
| const M extends StyledConfiguration<C>, | ||||||
| >( | ||||||
| baseComponent: C, | ||||||
| mapping: M, | ||||||
| mapping: M = defaultMapping as M, | ||||||
|
||||||
| mapping: M = defaultMapping as M, | |
| mapping: M, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
defaultMappinguses a generic type that may not match all component types used withstyled. Consider using a more flexible type or making it a function that returns the appropriate mapping type.