In this article, I’ll be covering how to create a pagination component in react with TypeScript. The aim is to make it as generic as possible. It will be a presentation component, also known as “dumb component” because it only displays the html with styles (doesn’t have state or logic).
As usual, my aim is to be able to have it working in less than 10 minutes. I’m going to build it with React TypeScript and using CSS Modules with Sass. I am starting to enjoying it a lot as it allows to localize the styling to your component so I don’t have to worry as much for the naming in the app. For testing, I’ll use jest with enzyme.
As a reference we’ll use the pagination component of Airbnb. You an see how it works on the image below. These are the main characteristics:
#jest #typescript #react #coding #programming