File tree Expand file tree Collapse file tree 4 files changed +28
-3
lines changed
Expand file tree Collapse file tree 4 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 44 "private" : true ,
55 "dependencies" : {
66 "axios" : " ^0.18.0" ,
7+ "prop-types" : " ^15.7.2" ,
78 "react" : " ^16.8.4" ,
89 "react-dom" : " ^16.8.4" ,
910 "react-scripts" : " 2.1.8"
Original file line number Diff line number Diff line change 11import React , { Component } from 'react' ;
22import axios from 'axios' ;
3+ import PropTypes from 'prop-types' ;
34import './App.css' ;
45
56const DEFAULT_QUERY = 'redux' ;
@@ -204,10 +205,22 @@ const Table = ({ list, onDismiss }) =>
204205 ) }
205206 </ div >
206207
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+ } ;
207220
208221const Button = ( {
209222 onClick,
210- className = '' ,
223+ className,
211224 children,
212225} ) =>
213226 < button
@@ -218,6 +231,16 @@ const Button = ({
218231 { children }
219232 </ button >
220233
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+
221244export default App ;
222245
223246export {
Original file line number Diff line number Diff line change @@ -47,13 +47,13 @@ describe('Button', () => {
4747
4848 it ( 'renders without crashing' , ( ) => {
4949 const div = document . createElement ( 'div' ) ;
50- ReactDOM . render ( < Button > Give Me More</ Button > , div ) ;
50+ ReactDOM . render ( < Button onClick = { ( ) => { } } > Give Me More</ Button > , div ) ;
5151 ReactDOM . unmountComponentAtNode ( div ) ;
5252 } ) ;
5353
5454 test ( 'has a valid snapshot' , ( ) => {
5555 const component = renderer . create (
56- < Button > Give Me More</ Button >
56+ < Button onClick = { ( ) => { } } > Give Me More</ Button >
5757 ) ;
5858 const tree = component . toJSON ( ) ;
5959 expect ( tree ) . toMatchSnapshot ( ) ;
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ exports[`App has a valid snapshot 1`] = `
4242exports [` Button has a valid snapshot 1` ] = `
4343<button
4444 className = " "
45+ onClick = { [Function ]}
4546 type = " button"
4647>
4748 Give Me More
You can’t perform that action at this time.
0 commit comments