diff --git a/public/consolidated/typescript.json b/public/consolidated/typescript.json index 1d3ece20..962adc01 100644 --- a/public/consolidated/typescript.json +++ b/public/consolidated/typescript.json @@ -15,5 +15,23 @@ "code": "type Exclusive = T | U extends Record\n ?\n | ({ [P in Exclude]?: never } & U)\n | ({ [P in Exclude]?: never } & T)\n : T | U;\n\n\n// Usage:\ntype A = { name: string; email?: string; provider?: string };\ntype B = { name: string; phone?: string; country?: string };\n\ntype EitherOr = Exclusive;\n\nconst w: EitherOr = { name: \"John\", email: \"j@d.c\" }; // ✅\nconst x: EitherOr = { name: \"John\", phone: \"+123 456\" }; // ✅\nconst y: EitherOr = { name: \"John\", email: \"\", phone: \"\" }; // ⛔️\nconst z: EitherOr = { name: \"John\", phne: \"\", provider: \"\" }; // ⛔️\n" } ] + }, + { + "name": "React Helpers", + "snippets": [ + { + "title": "Functional Component", + "description": "Functional component for React JS with props.", + "author": "gihanrangana", + "tags": [ + "typescript", + "fuctional-component", + "react-props", + "reactjs" + ], + "contributors": [], + "code": "import React from 'react';\n\ninterface ComponentNameProps {\n // Define specific props here\n}\n\nconst ComponentName: React.FC = (props) => {\n return (\n
\n {/* Add component content here */}\n
\n );\n};\n\nexport default ComponentName;\n" + } + ] } ] \ No newline at end of file diff --git a/snippets/typescript/react-helpers/functional-component.md b/snippets/typescript/react-helpers/functional-component.md new file mode 100644 index 00000000..ac795a53 --- /dev/null +++ b/snippets/typescript/react-helpers/functional-component.md @@ -0,0 +1,24 @@ +--- +title: Functional Component +description: Functional component for React JS with props. +author: gihanrangana +tags: typescript,fuctional-component,react-props,reactjs +--- + +```tsx +import React from 'react'; + +interface ComponentNameProps { + // Define specific props here +} + +const ComponentName: React.FC = (props) => { + return ( +
+ {/* Add component content here */} +
+ ); +}; + +export default ComponentName; +``` \ No newline at end of file