Components
Creating a stand-alone component
Let’s then create the button needed for displaying the list of Pokémon.
Create the following file src/components/PokemonLink.tsx
and fill the content with:
Now that the link is done, let’s import it into the index.tsx
file
Now the links work. Clicking on any of them, we get redirected to the 404 page because we haven’t yet implemented the pokemons/[pokemon]
page.
As previously said, CSS modules are enabled out of the box, so let’s make those links a little bit nicer.
Styling the component
Create alongside the PokemonLink.tsx
component the CSS module PokemonLink.module.css
and copy the following content into it:
💡 SASS is supported out of the box. Just install the processor in the devDependencies
npm i -D sass
and run againtuono dev
Then import the styles into the PokemonLink
component as following: