{"id":22051892,"url":"https://github.com/ohansemmanuel/polymorphic-react-component","last_synced_at":"2025-04-09T17:25:49.658Z","repository":{"id":37450748,"uuid":"466644034","full_name":"ohansemmanuel/polymorphic-react-component","owner":"ohansemmanuel","description":"Companion repo for my build a polymorphic React component class","archived":false,"fork":false,"pushed_at":"2023-05-03T13:07:35.000Z","size":799,"stargazers_count":274,"open_issues_count":8,"forks_count":40,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-01T20:16:37.746Z","etag":null,"topics":["react","reactjs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ohansemmanuel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-06T05:20:43.000Z","updated_at":"2025-03-25T20:50:14.000Z","dependencies_parsed_at":"2025-01-15T17:40:54.216Z","dependency_job_id":"3b5534e9-9ab6-434c-9f09-b716440ad953","html_url":"https://github.com/ohansemmanuel/polymorphic-react-component","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohansemmanuel%2Fpolymorphic-react-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohansemmanuel%2Fpolymorphic-react-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohansemmanuel%2Fpolymorphic-react-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohansemmanuel%2Fpolymorphic-react-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohansemmanuel","download_url":"https://codeload.github.com/ohansemmanuel/polymorphic-react-component/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248075989,"owners_count":21043682,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","reactjs","typescript"],"created_at":"2024-11-30T15:11:57.829Z","updated_at":"2025-04-09T17:25:49.641Z","avatar_url":"https://github.com/ohansemmanuel.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![https://i.imgur.com/oNNDQDC.png](https://i.imgur.com/oNNDQDC.png)\n\n\u003cbr /\u003e\n\n\u003e **Polymorphic**: occurring in several different forms, in particular with reference to species or genetic variation...\n\n\u003cbr /\u003e \n\u003cbr /\u003e\n\n# How to read the code\n\nRead the implementation snippets from `01` to `06`\n\n[01: A basic polymorphic component implementation](/01.tsx)\n\n[02: Handling relevant component props](/02.tsx):\n\n[03: Providing a default generic type](/03.tsx):\n\n[04: Handling unique component props](/04.tsx)\n\n[05: Building a reusable polymorphic type utility](/05.tsx)\n\n[06: Handling polymorphic components with Ref](/06.tsx)\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n# Relevant Links\n\n- [Live workshop details](https://devcher.com/class/build-strongly-typed-polymorphic-components-with-react-and-typescript-UWwzxjSxrh)\n\n- Watch me teach this [course on Udemy](https://www.udemy.com/course/build-polymorphic-components-with-react-and-typescript/?referralCode=DF6B523A0C852F2044DC)\n\n- [Presentation](https://excalidraw.com/#json=3mAFa-9SfI53dtQ6q5ykA,frb3BKbw-Zivudv-kixuVQ) on Excalidraw (open in incognito to not override your current drawings )\n\n- [use cases (PDF)](/use-cases.pdf)\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n## Read more\n\n- Polymorphic components in the wild: [Chakra UI](https://chakra-ui.com/docs/components/layout/box#as-prop) and [Material UI](https://mui.com/guides/composition/#component-prop)\n- JSX: [Choosing type at runtime](https://reactjs.org/docs/jsx-in-depth.html#choosing-the-type-at-runtime)\n- Typescript [Generics](https://www.typescriptlang.org/docs/handbook/2/generics.html)\n- Typescript Generics and arrow functions:\n  - [What's the syntax for generics in TS?](https://stackoverflow.com/questions/32308370/what-is-the-syntax-for-typescript-arrow-functions-with-generics?)\n  - [TS Github issue](https://github.com/Microsoft/TypeScript/issues/4922)\n- [Why color appears as HTML attribute on a div?](https://stackoverflow.com/questions/67142430/why-color-appears-as-html-attribute-on-a-div)\n- React Ref: [Forwarding Refs](https://reactjs.org/docs/forwarding-refs.html)\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n## Download the accompanying ebook and receive my 5-day typescript secrets newsletter\n\n[Download ebook here](https://www.ohansemmanuel.com/books/how-to-build-strongly-typed-polymorphic-react-components).\n\n\u003cbr /\u003e\n\n![https://i.imgur.com/U62L81u.png](https://i.imgur.com/U62L81u.png)\n\nYou'll automatically receive my 5-day newsletter to get you thinking and writing Typescript like a pro 🕺\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohansemmanuel%2Fpolymorphic-react-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohansemmanuel%2Fpolymorphic-react-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohansemmanuel%2Fpolymorphic-react-component/lists"}