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 trialLuis Onate
1,522 PointsHow would you enforce the types of expected data if you use the Context API?
As you refactor the code, you remove items from the propType object and I didn't see you checking the data anywhere else. To my understanding, that could lead to instances where a certain data type is expected, but a different data type is provided. Is there a recommended way to do data type validation with using the Context API?
1 Answer
Michael Cook
Full Stack JavaScript Techdegree Graduate 28,975 PointsMy guess would be with TypeScript. Instead of specifying prop types you'd write your code in TypeScript and get any errors or warnings when transpiling.