marcobax liked a comment+100 XP
5mos ago
marcobax started a new conversation+100 XP
5mos ago
Hi all! Just wanted to post a quick message and say I've been impressed and happy with Laracasts as a platform. Just finished my first course on React by Simon Vrachliotis which was excellent!
Coming from a PHP background it has been great fun properly trying out React for the first time!
How long have you been working with React? And what do you think are great tips for React beginners?
marcobax liked a comment+100 XP
5mos ago
marcobax liked a comment+100 XP
5mos ago
@andreich1980 The puppies made recording this course much more entertaining for me too! ❤️
marcobax wrote a comment+100 XP
5mos ago
@amr There is a separate course on React + Laravel + Inertia from Simon here: https://laracasts.com/series/react-the-laravel-way
marcobax liked a comment+100 XP
5mos ago
marcobax liked a comment+100 XP
5mos ago
We are not defining a count variable — we're using const to declare a reference to a state value managed by React.
The variable count itself doesn't get reassigned. It's always pointing to the current value returned by useState.
When we call setCount(...), React updates the internal state, and on the next render, count will hold the updated value.
marcobax wrote a comment+100 XP
5mos ago
Here's the link to the (React 19.2) Rules of Hooks page: https://react.dev/warnings/invalid-hook-call-warning
marcobax liked a comment+100 XP
5mos ago
it was actually better to init the variable for checking if the current puppy is liked before the return because now the same check is done twice and thus the whole liked array is iterated over twice. In this case it doesn't really matter since the array is really small and you won't notice any difference performance wise. But if you had a huge array you would notice it. These are small optimizations but I think at the end of the day they do matter the bigger your project gets :)
marcobax liked a comment+100 XP
5mos ago
@simonswiss Just for reference in case anyone sees this, restarting the dev server fixes the issue. I'm guessing the react plugin for vite handles it and the dev server needed restarting after adding it
marcobax liked a comment+100 XP
5mos ago
script tags for copy+paste: src="https://unpkg.com/[email protected]/umd/react.production.min.js" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js" src="https://unpkg.com/@babel/standalone/babel.min.js"