Skip to content

Commit

Permalink
added proptypes
Browse files Browse the repository at this point in the history
  • Loading branch information
JonAmparo committed Feb 25, 2020
1 parent aedd150 commit 99ebe5e
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 28 deletions.
54 changes: 31 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
"gh-pages": "^2.2.0",
"proptypes": "^1.1.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.4.0"
Expand Down
2 changes: 1 addition & 1 deletion src/App.js → src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function App() {
setFiltered(json.results);
setCount(count + 1);
setApi(true);
console.log('API call count:', count);
// console.log('API call count:', count);
})
.catch(e => console.error(e));
};
Expand Down
7 changes: 6 additions & 1 deletion src/Pokemon.js → src/components/Pokemon.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';

function Pokemon({ filtered, counter }) {
function Pokemon({ filtered }) {
const renderPokemon = () => {
return filtered.map((pokemon, index) => {
return (
Expand All @@ -19,4 +20,8 @@ function Pokemon({ filtered, counter }) {
);
}

Pokemon.propTypes = {
filtered: PropTypes.array.isRequired
};

export default Pokemon;
8 changes: 6 additions & 2 deletions src/Search.js → src/components/Search.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';

const Search = ({ searchPokemon }) => {
const [query, setQuery] = useState('');
console.log('SEARCH query:', query);

const handleSubmit = e => {
searchPokemon(query);
Expand All @@ -14,10 +14,14 @@ const Search = ({ searchPokemon }) => {
type='text'
value={query}
onChange={e => setQuery(e.target.value)}
placeholder="Search for a pokemon..."
placeholder='Search for a pokemon...'
/>
</form>
);
};

Search.propTypes = {
searchPokemon: PropTypes.func.isRequired
};

export default Search;
6 changes: 6 additions & 0 deletions src/Sort.js → src/components/Sort.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';

const Sort = ({ sort, sortType }) => {
const [sorted, setSorted] = useState(false);
Expand All @@ -20,4 +21,9 @@ const Sort = ({ sort, sortType }) => {
);
};

Sort.propTypes = {
sort: PropTypes.func.isRequired,
sortType: PropTypes.string.isRequired
};

export default Sort;
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import App from './components/App';

ReactDOM.render(<App />, document.getElementById('root'));

0 comments on commit 99ebe5e

Please sign in to comment.