Dead simple, advanced examples to learn to love react and some of its libraries.
MIT License
Dead simple, advanced examples to learn to love react and some of its libraries.
map()
to toggle each todo's completed statefilter()
method to delete itemmap()
method to toggle if todo is in edit modethis is dead simple - but edit mode should not be in the data we mock as a database, better keep your data structure clean from states that are only needed to render on the frontend.
new FormData()
and Object.fromEntries()
instead of controlled inputsfilter()
chained with map()
localStorage.setItem()
localStorage.getItem()
Note that this solution will not work in a ssr environment. For ssr use
useSyncExternalStore
or a dedicated library.
If you are looking for a better solution, you probably want to take a look at
splice()
method.
navigator.clipboard.writeText()
Depending on the browser, this will throw an error in Codesandbox's editor-mode, but will most likely work if you open the app in a new window.
Number.parseFloat()
Math.round()
Array.from()
While fetching with pagination it is not guaranteed, that responses arrive in the same order we request them, so we manually take care, that the last request will always be the last no matter if it responded faster than an earlier request.
window.addEventListener()
and window.removeEventListener()
filter()
map()
Note that zustand.js as a global state management system can be imported directly into components, no matter how deep they are nested in the tree.
useStore.getState().fetchPlanets()
syntax allows us leavingfetchPlanets
out of useEffect dependency arrayDoesn't have everything, but enough to gain a much deeper understanding.
children
, variant
, component
and every other prop you want to useSetting component (semantic) independently from variant (styling) separates concerns.
Does not have all the features by far, but the most basic functionality becomes more accessible and comprehensible.