Last active
April 18, 2019 01:06
-
-
Save xpsteven/915ca235c2caefed95b5b68fbfc37d8b to your computer and use it in GitHub Desktop.
React Function Component Pattern 1:用 Factory 封裝靜態變數
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** MyForm 實作 */ | |
const MyForm: React.FC<IMyFormStaticProps & IMyFormProps> = (props) => { | |
return ( | |
<form /> | |
); | |
}; | |
/** 工廠函數 */ | |
export default function MyFormFactory(sProps: IMyFormStaticProps) { | |
return (props: IMyFormProps) => ( | |
<MyForm {...props} {...sProps} /> | |
); | |
} | |
/** 靜態 props */ | |
export interface IMyFormStaticProps { | |
sName: string; | |
} | |
/** 執行時期 props */ | |
export interface IMyFormProps { | |
style: React.CSSProperties; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment