How to declare "propTypes" for React Hooks using React.useContext
Asked Answered
N

0

6

Given an app environment where typescript is not an option und React Hooks are used.

When using a context with ...

const myContext = useContext(MyContext)

...how would one declare the context signature in a way we know it from the propTypes-concept?

Would React use such a declaration for warnings?

I try to assure a warning is shown for my component if the context signature changes one day.

Nationalize answered 20/6, 2019 at 12:33 Comment(1)
React doesn't validate custom hooks or in-built hooks props. I completely recommend using TypeScript with Hooks check this levelup.gitconnected.com/…Gabble

© 2022 - 2024 — McMap. All rights reserved.