const useAuthContext = () => eContext(AuthContext) import React from "react" type Props = React.PropsWithChildren function Container( įinally, we will create a custom hook, that will be able to access this context from anywhere in the project. So here is how to create a Polymorphic component that can accept a union of HTML element types as a string. We need this wrapper to wrap our content in core HTML5 elements like aside or section. Let’s consider an example of creating a Container component for a UI library that acts as a wrapper for their child items. Make your UI component more accessible with the help of Polymorphism. In this part, we are going to expand our knowledge further and explore Event Handlers, Context, Hooks, and State with TypeScript. In Part 1 we explored native HTML types, Functional components, and Discriminated Unions and their pros and cons.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |