Skip to content

Commit 5587c37

Browse files
author
DEVfancybear
committed
Prop-types hoan thanh
1 parent 762201c commit 5587c37

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

example_1/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@testing-library/react": "^9.3.2",
88
"@testing-library/user-event": "^7.1.2",
99
"classnames": "^2.2.6",
10+
"prop-types": "^15.7.2",
1011
"react": "^16.12.0",
1112
"react-dom": "^16.12.0",
1213
"react-scripts": "3.3.0"

example_1/src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class App extends Component {
1313
{ title: "Đi shopping", isComplete: true },
1414
{ title: "Đi siêu thị", isComplete: false },
1515
{ title: "Nấu Cơm", isComplete: false },
16-
{ title: "Rửa Bát", isComplete: true }
16+
{ title: "Rửa Bát", isComplete: false }
1717
]
1818
};
1919
this.onKeyUp = this.onKeyUp.bind(this);

example_1/src/components/ItemTodo.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React, { Component } from "react";
2+
import PropTypes, { shape, bool } from "prop-types";
23
import "./ItemTodo.css";
34
import classNames from "classnames";
45
import imgCheck from "../img/check.svg";
56
import imgCheckDone from "../img/success.svg";
6-
class ItemTodo extends Component {
7+
class ItemTodo extends React.Component {
78
render() {
89
const { item, onClick } = this.props;
910
let url = imgCheck;
@@ -22,4 +23,11 @@ class ItemTodo extends Component {
2223
);
2324
}
2425
}
26+
ItemTodo.propTypes = {
27+
item: PropTypes.shape({
28+
isComplete: PropTypes.bool.isRequired,
29+
title: PropTypes.string.isRequired
30+
}),
31+
onClick: PropTypes.func.isRequired
32+
};
2533
export default ItemTodo;

0 commit comments

Comments
 (0)