Skip to content

Commit 1ee4c81

Browse files
committed
Revert "Component Interface with PropTypes (End 4 Chapter)"
This reverts commit 6ecaaef.
1 parent 6ecaaef commit 1ee4c81

File tree

4 files changed

+3
-28
lines changed

4 files changed

+3
-28
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"private": true,
55
"dependencies": {
66
"axios": "^0.18.0",
7-
"prop-types": "^15.7.2",
87
"react": "^16.8.4",
98
"react-dom": "^16.8.4",
109
"react-scripts": "2.1.8"

src/App.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { Component } from 'react';
22
import axios from 'axios';
3-
import PropTypes from 'prop-types';
43
import './App.css';
54

65
const DEFAULT_QUERY = 'redux';
@@ -205,22 +204,10 @@ const Table = ({ list, onDismiss }) =>
205204
)}
206205
</div>
207206

208-
Table.propTypes = {
209-
list: PropTypes.arrayOf(
210-
PropTypes.shape({
211-
objectID: PropTypes.string.isRequired,
212-
author: PropTypes.string,
213-
url: PropTypes.string,
214-
num_comments: PropTypes.number,
215-
points: PropTypes.number,
216-
})
217-
).isRequired,
218-
onDismiss: PropTypes.func.isRequired,
219-
};
220207

221208
const Button = ({
222209
onClick,
223-
className,
210+
className = '',
224211
children,
225212
}) =>
226213
<button
@@ -231,16 +218,6 @@ const Button = ({
231218
{children}
232219
</button>
233220

234-
Button.defaultProps = {
235-
className: '',
236-
};
237-
238-
Button.propTypes = {
239-
onClick: PropTypes.func.isRequired,
240-
className: PropTypes.string,
241-
children: PropTypes.node.isRequired,
242-
};
243-
244221
export default App;
245222

246223
export {

src/App.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ describe('Button', () => {
4747

4848
it('renders without crashing', () => {
4949
const div = document.createElement('div');
50-
ReactDOM.render(<Button onClick={() => {}}>Give Me More</Button>, div);
50+
ReactDOM.render(<Button>Give Me More</Button>, div);
5151
ReactDOM.unmountComponentAtNode(div);
5252
});
5353

5454
test('has a valid snapshot', () => {
5555
const component = renderer.create(
56-
<Button onClick={() => {}}>Give Me More</Button>
56+
<Button>Give Me More</Button>
5757
);
5858
const tree = component.toJSON();
5959
expect(tree).toMatchSnapshot();

src/__snapshots__/App.test.js.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ exports[`App has a valid snapshot 1`] = `
4242
exports[`Button has a valid snapshot 1`] = `
4343
<button
4444
className=""
45-
onClick={[Function]}
4645
type="button"
4746
>
4847
Give Me More

0 commit comments

Comments
 (0)