generated from Code-the-Dream-School/ctd-react
-
Notifications
You must be signed in to change notification settings - Fork 27
Lesson 4.1
Mary Alice Moore edited this page Feb 18, 2022
·
2 revisions
This lesson will teach you the following:
- Project Structure
- Typechecking with Prop Types
- Unit Testing
- Inside the
src/
directory, create a new folder namedcomponents/
- Move the following files into the
components/
directory-
AddTodoForm.js
-
InputWithLabel.js
-
TodoContainer.js
(stretch goal - you may not have this in your files) -
TodoList.js
-
TodoListItem.js
- Any CSS modules associated with the components above
-
- Open
src/App.js
- Update the import path for
TodoContainer.js
(stretch goal)
If you're using NPM, run
npm install --save prop-types
instead
yarn add prop-types
Documentation: https://reactjs.org/docs/typechecking-with-proptypes.html
-
Open
AddTodoForm.js
-
Import
PropTypes
from the "prop-types" package -
Below the
AddTodoForm
function, define thepropTypes
property of that function as a new object- Inside the object, define a property with key
onAddTodo
(prop name) and valuePropTypes.func
(function data type)
- Inside the object, define a property with key
-
Run your application and view in browser
- Verify that your Todo List still appears correctly with no console errors
Repeat the steps above for each of the following components, be sure to use the appropriate key/value pairs depending on the
props
for each:
- Verify that your Todo List still appears correctly with no console errors
Repeat the steps above for each of the following components, be sure to use the appropriate key/value pairs depending on the
-
InputWithLabel.js
-
TodoContainer.js
(stretch goal) -
TodoList.js
-
TodoListItem.js
View Instructions: https://github.com/Code-the-Dream-School/ctd-jest-unit-testing-practice