Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 074520f

Browse files
Add prop-types to all components.
1 parent 7771768 commit 074520f

File tree

6 files changed

+45
-0
lines changed

6 files changed

+45
-0
lines changed

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"dependencies": {
3131
"axios": "^0.18.0",
3232
"emotion": "^9.1.3",
33+
"prop-types": "^15.6.2",
3334
"react": "^16.3.2",
3435
"react-dom": "^16.3.2",
3536
"react-emotion": "^9.1.3",

‎src/components/App.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@
77
from containers.TodoListContainer import TodoListContainer
88

99
React = require("react")
10+
PropTypes = require("prop-types")
1011
Form, Row, Col, Jumbotron = destruct(
1112
require("reactstrap"), "Form", "Row", "Col", "Jumbotron")
1213

1314

1415
class App(Component):
16+
propTypes = {
17+
"logged_in": PropTypes.bool.isRequired,
18+
"error": PropTypes.string
19+
}
20+
1521
def render_login_panel(self):
1622
return __pragma__("xtrans", None, "{}", """ (
1723
<div>

‎src/components/ButtonPanel.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22
from Component_py.stubs import require, __pragma__ # __:skip
33

44
React = require("react")
5+
PropTypes = require("prop-types")
56
Button = require("reactstrap").Button
67

78

89
class ButtonPanel(Component):
10+
propTypes = {
11+
"text": PropTypes.string,
12+
"token": PropTypes.string.isRequired,
13+
"add_new_todo": PropTypes.func.isRequired,
14+
"form_panel_update": PropTypes.func.isRequired,
15+
"logout_user": PropTypes.func.isRequired
16+
}
17+
918
def on_click_add(self):
1019
text, token, form_panel_update, add_new_todo = destruct(self.props,
1120
"text", "token", "form_panel_update", "add_new_todo")

‎src/components/FormPanel.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
from Component_py.stubs import require, __pragma__ # __:skip
33

44
React = require("react")
5+
PropTypes = require("prop-types")
56
FormGroup, Label, Input = destruct(
67
require("reactstrap"), "FormGroup", "Label", "Input")
78

89

910
class FormPanel(Component):
11+
propTypes = {
12+
"text": PropTypes.string,
13+
"form_panel_update": PropTypes.func.isRequired
14+
}
15+
1016
def on_text_change(self, e):
1117
self.props.form_panel_update(e.target.value)
1218

‎src/components/LoginForm.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22
from Component_py.stubs import require, __pragma__ # __:skip
33

44
React = require("react")
5+
PropTypes = require("prop-types")
56
Form, FormGroup, Label, Input, Button = destruct(
67
require("reactstrap"), "Form", "FormGroup", "Label", "Input", "Button")
78

89

910
class LoginForm(Component):
11+
propTypes = {
12+
"username_text": PropTypes.string,
13+
"password_text": PropTypes.string,
14+
"login_form_update": PropTypes.func.isRequired,
15+
"clear_login_form": PropTypes.func.isRequired,
16+
"login_user": PropTypes.func.isRequired,
17+
"register_user": PropTypes.func.isRequired
18+
}
19+
1020
def on_input_change(self, e):
1121
self.props.login_form_update(e.target.id, e.target.value)
1222

‎src/components/TodoList.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,38 @@
22
from Component_py.stubs import require, __pragma__, window # __:skip
33

44
React = require("react")
5+
PropTypes = require("prop-types")
56
ListGroup, ListGroupItem, Button = destruct(
67
require("reactstrap"), "ListGroup", "ListGroupItem", "Button")
78
RingLoader = require("react-spinners").RingLoader
89
FontAwesomeIcon = require("react-fontawesome")
910

1011

1112
class TodoList(Component):
13+
propTypes = {
14+
"token": PropTypes.string.isRequired,
15+
"todos": PropTypes.array.isRequired,
16+
"loading": PropTypes.bool.isRequired,
17+
"error": PropTypes.string,
18+
"fetch_all_todos": PropTypes.func.isRequired,
19+
"complete_todo": PropTypes.func.isRequired,
20+
"delete_todo": PropTypes.func.isRequired
21+
}
22+
1223
def componentDidMount(self):
1324
self.props.fetch_all_todos(self.props["token"])
1425

1526
def on_click_complete(self, todo):
1627
token, complete_todo = destruct(self.props, "token", "complete_todo")
28+
1729
def closure():
1830
if not todo["complete"]:
1931
complete_todo(todo["id"], token)
2032
return closure
2133

2234
def on_click_delete(self, todo):
2335
token, delete_todo = destruct(self.props, "token", "delete_todo")
36+
2437
def closure():
2538
if todo["complete"] or window.confirm('Delete incomplete Todo?'):
2639
delete_todo(todo["id"], token)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /