Перейти к содержимому

Product List & Cart in React, Part 7: Faking a Login

rge

0:00 / 0:00

Product List & Cart in React, Part 7: Faking a Login

5 просмотров · 13 дн. назад
rge
50 подписчиков
5 просмотров · 13 дн. назад
We gate the whole app behind a login — a fake one, with no password and no real server checking anything, and we say so clearly, twice. A username-only login sets a user in state, an early return swaps the whole app for a login page when there's nobody logged in, and the login survives a refresh using localStorage — read back with useState's lazy initializer instead of useEffect, since unlike the fetch back in Part 1, reading localStorage isn't asynchronous. Playlist:    • Building Things in React