Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJoseph Lander
Full Stack JavaScript Techdegree Graduate 27,765 PointsRemoving propTypes when using Context - no more error/type checking?
As we move through the course and use Context
to access properties of state
, we also remove the Type Checking. This makes sense as the Prop Types
is specifically checking properties.
However, we introduced it to check for human error in passing down the correct information. Why isn't there a method to state the prop type when you create it in state
? Like how if we create a const
variable and try to change it anywhere, the console will display an error. As it stands we have cut down on drilling
but removed the check for human error. I'm sure the assumption isn't that we will not make errors if passed from the original state to the component, right?
1 Answer
Joseph Lander
Full Stack JavaScript Techdegree Graduate 27,765 Points[DUPLICATE] I see someone else had the same idea here a year ago: https://teamtreehouse.com/community/how-would-you-enforce-the-types-of-expected-data-if-you-use-the-context-api
Currently, one response suggesting using Typescript.
Please add answers to the end of their question.