Let’s make a Cat List App
In this tutorial, you will learn how to build a simple Cat List App with React﹤Kitten﹥.
Create a new React﹤Kitten﹥ project
First, create a new React﹤Kitten﹥ project by running the following command:
Install React﹤Kitten﹥
Next, install React﹤Kitten﹥ by running the following command:
Create a Cat List component
Create a new file named CatList.tsx
in the src
directory with the following content:
What’s happening here?
- The
ListWindow
component is a functional component that displays a list of cat images.
- We use
usePosition
, useSize
, and useKittenId
hooks to manage the window’s position, size, and Kitten ID.
- We fetch a list of cat images from the
https://blanch.dev/catphotos/cats.php?count=10
API using the fetch
function.
- When a cat image is clicked, it opens a new
BasicWindow
with the cat image.
- We’ve used
BasicWindow
to show a simple window that displays an image of a cat.
Use the Cat List component in your App
Now, you can use the ListWindow
component in your App.tsx
file:
Congratulations 🥳
You have successfully built a Cat List App with React﹤Kitten﹥.