···3535}
36363737export const UserBookmarks: FunctionComponent<Props> = ({ user }) => {
3838- const [bookmarks, setBookmarks] = useState<Bookmark[]>([])
3938 const [showAddBookmarkModal, setShowAddBookmarkModal] = useState(false)
3939+ const [bookmarks, setBookmarks] = useState<Bookmark[]>([])
4040 const [isLoading, setIsLoading] = useState(false)
41414242 useEffect(() => {
···159159## The secret sauce
160160161161Now comes where we'll challenge how the component does its magic.
162162+163163+### Tell me about your hooks, I'll tell you who you are
164164+165165+Without being a rule of thumb, I like to count how many `use` there are in the component, it gives me good approximation about how many responsibilities lies.
166166+167167+1. `const [showAddBookmarkModal, setShowAddBookmarkModal] = useState(false)`
168168+2. `const [bookmarks, setBookmarks] = useState<Bookmark[]>([])`
169169+3. `const [isLoading, setIsLoading] = useState(false)`
170170+4. `useEffect(() => {`
171171+172172+4 hooks, is it too many? too few? I guess it depends but here we can see there are 3 hooks managing fetching the data and one handling the modal for adding a bookmark. We can update our CRC Card.
173173+174174+<CrcCard
175175+ name="UserBookmarks"
176176+ responsabilities={[
177177+ "Display user bookmarks",
178178+ "fetching bookmarks",
179179+ "handling async processes",
180180+ "handling add bookmark modal visibility",
181181+ ]}
182182+ collaborators={["Home.tsx"]}
183183+/>
184184+185185+### The ugly responsability
186186+187187+The main problem I see in the `UserBookmarks` component is not about the component itself, it's more on one of its children: `TilesSkeleton`. It's doing a good job for the user experience but it's asking too much for the parent to be able to use it: `UserBookmarks` doesn't care about animating the skeleton.
188188+189189+```tsx
190190+const tilesAnimation = gsap.to({
191191+ duration: 0.8,
192192+ opacity: 0.35,
193193+ yoyo: true,
194194+ repeat: -1,
195195+ stagger: 0.025,
196196+})
197197+// ...
198198+<TilesSkeleton animation={tilesAnimation} numberOfTiles={16} />
199199+```
200200+201201+<CrcCard
202202+ name="UserBookmarks"
203203+ responsabilities={[
204204+ "Display user bookmarks",
205205+ "fetching bookmarks",
206206+ "handling async processes",
207207+ "handling add bookmark modal visibility",
208208+ "⚠️ Defining TilesSkeleton animation",
209209+ ]}
210210+ collaborators={["Home.tsx"]}
211211+/>
212212+213213+It must become
214214+215215+```tsx
216216+// removing the magic number at the same time
217217+<TilesSkeleton numberOfTiles={MAXIMUM_BOOKMARKS} />
218218+```