-
Notifications
You must be signed in to change notification settings - Fork 714
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
how can I define prop type when set a custom props? #1442
Comments
|
in modifiers.d.ts
|
Is there a better way? |
@zwh1666258377 |
@ethanshar okay, I can try |
@ethanshar Can you tell me briefly about your thoughts? |
Oh, I think I see what you mean. Like this we can type BorderRadiuses = `br${number}`; But that's not what I meant. When I set other props // In a situation like this, This is how I handle it
const customTypography = {
// fontSize
"fs-10": { fontSize: 10 },
"fs-12": { fontSize: 12 },
// lineHeight
"lh-10": { lineHeight: 10 },
"lh-12": { lineHeight: 12 },
// fontWeight
"fw-400": { fontWeight: "400" },
"fw-500": { fontWeight: "500" },
};
type GetCustomType<T> = Partial<{ [k in keyof T]: boolean }>;
type TCustomTypography = GetCustomType<typeof customTypography>;
export interface ITextCustomProps extends TCustomTypography {}
// In modifiers.d.ts
declare module "react-native-ui-lib" {
import type { ITextCustomProps } from "@/utils/initUiLibModifiers";
export * from "react-native-ui-lib/generatedTypes";
import type { default as Text, TextProps } from "react-native-ui-lib/generatedTypes/components/text";
export declare const Text: React.ComponentClass<
TextProps & {
useCustomTheme?: boolean | undefined;
} & ITextCustomProps,
any
>;
}
// When I use
...
render(){
// There will be type hints
return <Text fs-10 fw-10 fw-400> ... </Text>
}
... |
I'm a junior programmer and would love to be able to commit changes, but I think I need some guidance. Thank you very much |
hey, this is my PR #1463 |
Hi @ethanshar If I understand correctly, you decided on adding a dynamic typing for BorderRadius right? |
Yes |
Hi @zwh1666258377 |
@ethanshar oh… ok |
how can I define prop type when set a custom props?
The text was updated successfully, but these errors were encountered: