Components
Creating a standalone component
Let’s start by creating a link component to display each Pokémon in the list.
Create the src/components/PokemonLink.tsx
file and paste the following content:
Now that the component is ready, import it and use it in the index.tsx
file
Now we have working links!
However, clicking on them won't work yet because the pokemons/[pokemon]
route hasn't been implemented.
Styling a component
As already mentioned, CSS modules are supported out of the box, so let’s make the links more presentable.
Create the PokemonLink.module.css
stylesheet alongside PokemonLink.tsx
and paste the following content:
💡 SASS is supported with no extra configuration. Just install the processor in the
devDependencies
withnpm i -D sass-embedded
and runtuono dev
again
Then import the styles in the PokemonLink
component and provide them via the className
prop to the Link
component: