| 1234567891011121314151617181920212223242526272829303132333435363738 |
- import React from 'react';
- import PropTypes from 'prop-types';
- import {Link} from 'react-router-dom';
- import {Pokemon} from '../../../api';
- class PokemonShow extends React.Component {
- static propTypes = {
- match: PropTypes.object.isRequired,
- };
- state = {
- pokemon: {},
- };
- async componentDidMount() {
- try {
- const data = await Pokemon.get(this.props.match.params.id);
- this.setState({pokemon: data.data});
- } catch (err) {
- // eslint-disable-next-line no-console
- console.log(JSON.stringify(err, null, 2));
- }
- }
- render() {
- return (
- <>
- {this.state.pokemon.id}: {this.state.pokemon.nickname}
- <p>
- <Link to={`${this.props.match.url}/404`}>404 page</Link>
- </p>
- </>
- );
- }
- }
- export default PokemonShow;
|