Jan Hesters
Jan Hesters
  • 11
  • 16 288
How To Set Up Next.js 15 For Production In 2024
Want to hire a senior React developer? Visit reactsquad.io/jan now!
If you’re expanding your team and need to hire React developers book your free discovery call today! 👉 www.reactsquad.io/schedule-a-call
--------------------------------------------------------------
Learn how you can set up a scalable Next.js app (with React). This video covers everything from initial configuration with TypeScript, Tailwind CSS, and ESLint to advanced topics like internationalization (i18n), database integration using Prisma, and end-to-end testing with Playwright.
This tutorial shows you how to set up Next.js 15 for production and is the perfect guide to learn a Next.js production setup when you want to set up Shadcn in Next.js and test your app with Vitest.
-------------------------------------------------------------
What to watch next & next steps:
• 12 Keys to Write Senior-Level Tests (Test Desiderata in JavaScript): ua-cam.com/video/htraT8Qn4Rw/v-deo.html
• Unleash JavaScript's Potential with Functional Programming: ua-cam.com/video/xw5SJZnTWp4/v-deo.html
• Grab the code on GitHub: github.com/EarlyNode/tutorials/tree/main/examples/2024-07-16-set-up-next-js-production
• Prefer reading? Read the article here: janhesters.com/blog/how-to-set-up-nextjs-15-for-production-in-2024
-------------------------------------------------------------
Follow all of these to become a 10x developer:
• X - x.com/janhesters
• Jan Hesters - janhesters.com/
• LinkedIn - www.linkedin.com/in/jan-hesters/
And remember to subscribe here on UA-cam now!
--------------------------------------------------------------
If you’re new to my channel, my name is Jan Hesters. I’m the CTO of ReactSquad.io. It’s a marketplace of vetted senior React developers for SaaS companies. We provide developers to dozens of companies, including some in the Fortune 500.
--------------------------------------------------------------
For any questions or inquiries regarding this video, or working with Jan Hesters & ReactSquad, please reach out to: jan@reactsquad.io
--------------------------------------------------------------
Chapters:
00:00 Getting Your Production Setup Right
00:46 Initialize Your Project
01:18 Code Formatting
01:40 Prettier
02:00 ESLint
02:50 Commitlint & Husky
04:23 Folder Structure
05:58 Vitest
06:24 React Testing Library
07:25 Styling (Shadcn & Tailwind)
08:03 Internationalization (i18n)
11:38 Database (Postgres & Prisma)
15:31 Facades
16:34 Vercel Postgres
17:45 Playwright
19:10 Github Actions
Переглядів: 1 679

Відео

What Is Memoization? (In JavaScript And TypeScript)
Переглядів 31528 днів тому
Want to hire a senior React developer? Visit reactsquad.io/jan now! If you’re expanding your team and need to hire React developers book your free discovery call today! 👉 www.reactsquad.io/schedule-a-call What is memoization in JavaScript? How does memoization work? Get answers to these questions and more in this memoization and caching video tutorial. Learn how to use memoization to speed up y...
Unleash JavaScript's Potential With Functional Programming
Переглядів 3,7 тис.Місяць тому
Want to hire a senior React developer? Visit reactsquad.io/jan now! If you’re expanding your team and need to hire React developers book your free discovery call today! 👉 www.reactsquad.io/schedule-a-call What is functional programming? Using this tutorial, you can learn functional programming with JavaScript. Explore the functional programming paradigm in JavaScript. This "step-by-step with no...
Higher-Order Components Are Misunderstood In React
Переглядів 1,7 тис.Місяць тому
Want to hire a senior React developer? Visit www.reactsquad.io/jan now! If you’re expanding your team and need to hire React developers book your free discovery call today! 👉 www.reactsquad.io/schedule-a-call What are higher-order components in React? How do you use higher-order components? In this tutorial, you're going to learn the definition of React higher-order components. This guide shows...
12 Keys to Write Senior-Level Tests (Test Desiderata in JavaScript)
Переглядів 3762 місяці тому
Want to hire a senior React developer? Visit www.reactsquad.io/jan now! If you’re expanding your team and need to hire React developers book your free discovery call today! 👉 www.reactsquad.io/schedule-a-call In this video, you'll learn 12 testing best practices that every senior developer should know. You will see real-world JavaScript examples for Kent Beck’s article "[Test Desiderata](medium...
JavaScript Generators Explained, But On A Senior-Level
Переглядів 1,5 тис.2 місяці тому
Want to hire a senior React developer? Visit www.reactsquad.io/jan now! If you’re expanding your team and need to hire React developers book your free discovery call today! 👉 www.reactsquad.io/schedule-a-call What is a JavaScript generator function? In this video, you'll dive deep into how JavaScript generators work, exploring concepts like push and pull streams, lazy and eager data processing,...
Build A React Native App With Multiple Screens Masterclass
Переглядів 1,5 тис.3 місяці тому
Want to hire a senior React developer? Visit www.reactsquad.io/jan now! If you’re expanding your team and need to hire React developers book your free discovery call today! 👉 www.reactsquad.io/schedule-a-call How to build an Expo React Native app with complex navigation and multiple screens? In this tutorial you'll learn how to create a React Native app with nested navigators. You'll also see h...
useCallback vs. useMemo
Переглядів 3,9 тис.4 місяці тому
Want to hire a senior React developer? www.reactsquad.io/jan now! If you’re expanding your team and need to hire React developers book your free discovery call today! 👉 www.reactsquad.io/schedule-a-call What is the difference between useCallBack and useMemo? When should you use useMemo and useCallback? In this video tutorial you’ll learn how to use these two React hooks and see some real-world ...

КОМЕНТАРІ

  • @alvierime
    @alvierime 2 дні тому

    Internationalization needs a dedicated tutorial

  • @sefatanam
    @sefatanam 2 дні тому

    That was a banger, dude! Keep it up-you’re gonna level up for sure! 🔥

    • @JanHesters
      @JanHesters День тому

      Thanks for the kind words!

  • @peepoclown5838
    @peepoclown5838 5 днів тому

    This video gave me a headache...

  • @vinkrins
    @vinkrins 6 днів тому

    I liked this video, it have explained many javacript concepts, but the code suggested at 30:56 is not working correctly, inspite of addition via add3, its returning NaN, because pipe(...fns) .... is not able to pass all params to add3(), add3 is able to receive on first param only, @Jan Hesters, pls check,

  • @Pushpaje2130
    @Pushpaje2130 7 днів тому

    Amazing video ❤

  • @mattymattffs
    @mattymattffs 7 днів тому

    Question, are the terrible shirts a requirement too?

    • @JanHesters
      @JanHesters 6 днів тому

      Right into the feels! 💔😄 Wear whatever you want 😉

  • @dreamsachiever212
    @dreamsachiever212 8 днів тому

    You gotta love YT algorithm. Spent 3 days setting up a monorepo using turborepo, hell of a pain... Could you create a similar video on setting up for production for a monorepo?

    • @JanHesters
      @JanHesters 6 днів тому

      Absolutely! But it will take a few months, I have a bunch of other topics planned first. Thank you for the compliment and the suggestion! 🙏

  • @HowieRhee
    @HowieRhee 8 днів тому

    Well done. Very good video. And thank you for posting the code in GitHub.

  • @Myhic-lt4xy
    @Myhic-lt4xy 9 днів тому

    This is a rare channel, and I love the atmosphere your in.

    • @JanHesters
      @JanHesters 6 днів тому

      Appreciate it! I like shooting outside because we are inside enough as developers haha

  • @mehmethanifierenler3612
    @mehmethanifierenler3612 10 днів тому

    very very thanks

  • @husseinkizz
    @husseinkizz 10 днів тому

    Functional Programming oof, thanks surely, am subscribing!

  • @markschneidermann
    @markschneidermann 10 днів тому

    dope style & crazy gold nuggets bro !

    • @JanHesters
      @JanHesters 6 днів тому

      I have the privilege of working with the best when it comes to style 😉 Thanks!

  • @niyasp5265
    @niyasp5265 14 днів тому

    wow ..Best explanation ..

  • @nicolasfiore
    @nicolasfiore 19 днів тому

    Just one question: where you in the movie Split by M. Night Shyamalan?

    • @JanHesters
      @JanHesters 19 днів тому

      A few of me were, yes 😉

  • @CottidaeSEA
    @CottidaeSEA 19 днів тому

    In your curry function you copy memory four times just for the sake of immutability, which is already guaranteed by just doing 1 + 1. You'll have awful performance and you're using it for a simple addition? At least use a good example. I also really do not agree that this code is any more or less testable than OOP code. The problem is always state and keeping it correct at all times. That is usually not due to any one function being incorrect, it is due to developers making simple logic mistakes. Most bugs I've found in production are impossible to find with unit testing, because that's not where the bug is. Most of all, I just think JavaScript is a candidate for FP due to performance reasons. You don't really have to do much in order to get JavaScript to absolutely chug and lock down the browser, and on the server there's just so many more performant options. Even Java is more performant, then there's Kotlin even in the JVM world which tends to be more performant. C#, C++, Rust, Go, all of them are more performant. That's for the languages not even specifically for FP.

    • @JanHesters
      @JanHesters 19 днів тому

      Absolutely agree. I said at the end of the video that the examples in this video are contrived and optimized to be understandable. I disagree that OOP coder is easier to test because by default class inheritance is the tightest form of coupling and frequently requires mocking. But if you have good examples for OOP code that is easier to test than pure functions, please kindly point me to it 🙏 And regarding performance, IMO you should favour readability over performance UNTIL performance becomes a bottleneck. I can't speak to those other languages you mentioned because I'm specialized in JavaScript.

    • @CottidaeSEA
      @CottidaeSEA 19 днів тому

      ​@@JanHesters Easily testable OOP code honestly follows the same guidelines. Given the same input, you should get the same output. The thing that tends to get people thrown off is that with OOP and stateful classes, you'll have adjusted one of the inputs if you run the same method twice. In order to replicate the same thing you also need to replicate the class instance. Just with a really basic class (pure garbage I'd never write normally, so sorry about it being a bad example): class Addition { value; constructor(initial) { this.value = initial; } execute(value) { this.value += value; return this; } } assert(new Addition(2).execute(2).value, 4) would be 4, every single time you run it; same as FP. If you chain it like new Addition(2).execute(2).execute(2).value then you've fundamentally changed what it does, just like FP. Same principle, different execution. The class example is extremely stupid though, wouldn't write code like that normally, state is best stored in DB regardless. One of the benefits to using classes in JavaScript is that while it looks as if the objects all have their own methods, they are all only allocated once, which is a major benefit to anonymous functions added to objects which need to be allocated every time. This is not as important now with imports and exports being a thing, but look into how stupidly much memory is used in a regular application due to all of the object nonsense JavaScript injects since it needs to treat everything like a nondescript object. That's not the case in Java or C# for example, where they only keep the bare minimum to identify the class. As for why I think a lot about performance, it's because I work with larger datasets frequently, so I have to walk the tightropes of readability and performance a lot. This is true for both backend and frontend things; where updating/inserting 50k DOM elements is hell and takes ages even in a best case scenario, whereas remaking the entire HTML structure as a string and replacing all of it takes a few seconds. However, it only takes a few seconds under the assumption that I reuse memory through not allocating anything extra. This means reusing variables and pre-allocating memory as much as possible. I do enjoy FP though, I reach for it whenever possible, but only when I can afford doing so. I never do anything particularly crazy with it either, but the idea of passing functions to other functions is something I use regardless of FP or OOP. Command pattern is just that. The Addition class I gave as an example would be one of the classes one would pass to something that processes it. Somewhat unreadable, but with enough complexity in the business logic, it's totally worth it. Sorry about the long reply, not sure if you're going to read it either, but I hope my sleep-deprived brain didn't spew out too much nonsense.

    • @JanHesters
      @JanHesters 19 днів тому

      @@CottidaeSEA Thanks for the long reply! I for sure read it 🙏 Got it. As you said, the code you gave as an example is different from how you'd write it, but let me still address it because it demonstrates one of the problems I had with testing (and reading / understanding classes) as opposed to FP - even in production codebases with "real" code examples: You need to set up the internal state to run the different functions, and it's hard to understand a method in isolation. For example, if you had another method on that class, that would only do something if `value` was three, you'd need to either call `execute` three times, complicating the test. Or you'd need to manipulate the class directly, which then would obfuscate the test so it resembles the real usage less. With FP and pure functions, they usually map one input to an output, making it trivial to write tests for them and truly test them in isolation. And thank you for clarifying where you come from. Totally makes sense that you think about performance so much! 👍 I've been a fullstack dev for most of my career and over time I learned the best approach to browser performance is "fix it if it breaks, otherwise favor good DX (testability, readibility etc.)". (Most) Browsers are so fast nowadays that it doesn't matter if you take up extra memory. > I reach for it whenever possible, but only when I can afford doing so This pretty much sums it up! 😊 And in my experience, in most JS server and browser codebases, you don't need to optimize for performance so granularly. (Especially on the backend, if performance mattered, the teams switched to Rust or another fast language haha) Thanks again for your thoughtful reply!

  • @privacyvalued4134
    @privacyvalued4134 20 днів тому

    0:13 Nope! Using the splat operator = automatic fail. Simply put, you don't understand how expensive that operator is and that it should only ever be used very sparingly. Go write a DSL from scratch in a real programming language and implement the splat operator as part of it to learn how wrong your first 15 seconds of this video is. Splat may be convenient but trash like that it is why my web browser is chugging 10GB RAM half of the time. The rest of your example is what I call "symbol soup." It's unreadable because it uses symbols instead of words. Good coding practices balance words and symbols in a pleasing, easy to read/understand experience.

    • @JanHesters
      @JanHesters 19 днів тому

      The examples in this video are NOT meant to be production code, but just to teach the concepts of FP. (I mention it at the end of the video.) But your comment is good advice, I hope more people read it!

  • @basedest4451
    @basedest4451 20 днів тому

    I remember struggling with memoization 2 years ago doing related task on my first job. I wish I had this video back then. S-tier content. You deserve more subsribers bro

    • @JanHesters
      @JanHesters 19 днів тому

      Thank you for the kind words! 🙏 That's exactly the target audience. So far, this video received less views than my other ones, but I hope people who really need to find it, find it through SEO :)

  • @demarcorr
    @demarcorr 21 день тому

    functional programming is the kind of programming i do at 3am after being awake for 20+ hours. jokes aside, FP is great but just like OOP, going too heavy and far into FP and you just end up in a different web of frankly painful complexity. I get the piping and composing and currying but man I can absolutely see how someone would be utterly lost looking at that, and its not fun to try and understand. FP and OOP compliment each other well, and I've personally found myself writing my "best" or at least "better" code by using FP and OOP together, but never going to far into one or the other. Def a good vid though very succinct, I would prob reco up to about 25:44 for most people

    • @JanHesters
      @JanHesters 20 днів тому

      Thank you for the kind words! And I agree, always choose the right tool for the job and take into account what your team knows! 👍

  • @xyangst
    @xyangst 24 дні тому

    Insane thumbnail

  • @KeganVanSickle
    @KeganVanSickle 27 днів тому

    Exposing all the "magic" under the hood. This was very helpful in understanding memoization. Great video!

    • @JanHesters
      @JanHesters 24 дні тому

      Thank you and you're welcome! What topic would you like to see covered next?

  • @StupidInternetPeople1
    @StupidInternetPeople1 27 днів тому

    You wish you looked like that thumbnail 😂

  • @deatho0ne587
    @deatho0ne587 27 днів тому

    Do not assume that JS GC is always fast and that the new array/object is minor time spent. When it comes to million+ those things matter in terms of speed. I am not saying you should avoid functional programming in most cases, just know your rough max cases when dealing with Map, Set, Array stuff, and functional programming.

    • @JanHesters
      @JanHesters 24 дні тому

      Absolutely! Basically: Readability > Cleverness > Performance as long as performance doesn't matter. As soon as it does, the order switches.

  • @petemoss3160
    @petemoss3160 28 днів тому

    Wait, I thought this was Aphex Twin music video ;)

  • @szeredaiakos
    @szeredaiakos 29 днів тому

    FP patterns are the best way to write class methods :D

    • @JanHesters
      @JanHesters 24 дні тому

      I see what you did there lol

  • @coolaj86
    @coolaj86 Місяць тому

    But at what cost? Clear > Clever. (the video was well done, but I walked away more firmly in the camp of "we should never allow this in a shared codebase")

    • @JanHesters
      @JanHesters Місяць тому

      I mostly agree! But I disagree in certain circumstances. If you cannot train the team for whatever reason, then "yes," you should go with the best solution that everyone understands. Or if functional programming would objectively be the worst solution, then also "yes," you shouldn't use these techniques. But, if you have a team with a culture of mentorship and functional programming is the best solution, you should definitely level the team up and implement the cleanest solution.

    • @coolaj86
      @coolaj86 Місяць тому

      @@JanHesters Have you ever tried to level up a team? Just getting basic automatic formatting, linting, and PR reviews implemented for the code that's there already is an absolute war of attrition. Well... I guess those are all boring things. There's probably a bigger market for people trying some new cool thing and feeling special about how smart they've become than doing the essential and tedious work of figuring out why core functions of the application are failing, seemingly at random, and any tiny change to something that changes the timing of database calls creates cascading failures... Of course, a big problem in the code base I'm thinking of is that they did use so much fp - but in all the wrong ways - using reducers to filter and create new objects, using maps to iterate over and mutate objects... most people aren't disciplined enough to use any of it correctly. They would be better of just sticking to for loops rather than creating things that no one else (or even they themselves) can read. You know what would be a really useful video? How to reset VSCode to a default working state after years of use. So many people disable all of the linting and other code tools and then things that should "just work" don't - because they've been disabled. If you're working with really next-level, hyper-intelligent people of a similar mindset I imagine that fp could be really fun and not hinder productivity, but we're at a state in technology where it's too much to expect people to get a contact form to work reliably. The hello worlds are failing. We need the simple for loops so that people can read what they wrote themselves. Most people need fewer tools, that they know how to use correctly, not more tools that they don't understand the nuance of. When I was young and all of that was being added to JavaScript, I used to think all those things were so cool and even used some of it correctly. Now... htmx is starting to look better all the time.

    • @coolaj86
      @coolaj86 Місяць тому

      What tools do you have for leveling up a team? How do you approach it? How do you get people interested in quality and correctness over coolness and "if it fits it ships"ness?

    • @JanHesters
      @JanHesters Місяць тому

      ​@@coolaj86 > What tools do you have for levelling up a team? In my opinion, one-to-many and one-on-one mentorship is the most important tool for any dev team. > How do you approach it? Make sure that you have regular mentorship sessions with your team. Lead by example. > How do you get people interested in quality and correctness over coolness and "if it fits it ships"ness? Show them your arguments. If they agree, your arguments are good. If they disagree, that might be because you have a blind-spot. To answer all of these questions, might take its own proper video. I'll put in my backlog. Thanks for the idea! But I hope this somewhat answered your questions. If you have follow up questions, let me know. And if you disagree, I'd also be interested in your view! 🤓

  • @abdelhadiamhamdi
    @abdelhadiamhamdi Місяць тому

    Thank you for your amazing content! I've found it incredibly helpful and was wondering if you could assist me with some topics related to arity.

    • @JanHesters
      @JanHesters Місяць тому

      Sure! If you want, you can drop your question here, or DM me on X: x.com/janhesters

  • @muesli2kanal585
    @muesli2kanal585 Місяць тому

    Now I want currywurst

    • @JanHesters
      @JanHesters Місяць тому

      Don't forget the Sauerkraut! 😄

  • @rakeshgadave
    @rakeshgadave Місяць тому

    Is this video going to help me to learn React?

    • @JanHesters
      @JanHesters Місяць тому

      Implicitly yes, absolutely! A good understanding of the language helps you understand any JS framework better. And for React specifically, it can help you clean up your code in general. It'll also help you to understand higher-order components, selectors in Redux, and why thinks are rendering (closure).

    • @rakeshgadave
      @rakeshgadave 28 днів тому

      ​@@JanHestersThank you.

  • @Teneedev
    @Teneedev Місяць тому

    Thank you Jan

  • @lookasinsky
    @lookasinsky Місяць тому

    I know that you wanted to show functional programming, but the example at the very beginning of the movie requires a lot of cognitive load so I would not say that we should write code like this. I've seen some projects where functional programming was in use and unfortunately I have to say that some parts of the project were too advanced in terms of the way how function currying was used. Thumbs up anyway.

    • @JanHesters
      @JanHesters Місяць тому

      Thank you for your feedback! I agree and this is one of the last points of the video at the end 👍 Many of the examples are contrived to be as easy as possible. The goal of this video is to learn FP as opposed to real world use cases.

  • @kairollmann
    @kairollmann Місяць тому

    Great presentation! But please everyone, be mindful when you're working in a team. It'll be rare that others in your team have studied and understood fp as much as you did. "Real" senior developers understand the value of easy-to-read, easy-to-maintain code. Junior devs create simple code for everyone on the team. Mid-level devs create opinionated, seemingly "so efficient", "so elegant" code. Senior devs create simple code again. I'll always remember how everyone on a team hated that one guy who added Ramda to the codebase and now they all had to work with it after he left. He was clearly smart and knew what he was doing, but he wasn't mindful of the team or of anyone coming after him. If in doubt, don't be that one guy who adds Ramda.

    • @JanHesters
      @JanHesters Місяць тому

      I totally agree! Code readability and maintainability should always be a top priority. It's a balancing act between writing efficient code and ensuring that everyone on the team can understand and maintain it long-term. 1.) Sometimes, you want to use the best patterns AND teach the people who don't know them those patterns. (Especially in a mentorship-culture.) 2.) In other cases, you want to reach for the best tool that everyone knows. ("When in Rome, do as the Romans do.") My mentor taught me both.

  • @-N0PE-
    @-N0PE- Місяць тому

    This is the best Javascript Video I've ever seen. (And I've been coding in JS since 8 years). Big kudos!

    • @JanHesters
      @JanHesters Місяць тому

      Thank you for the kind words! 🙏

  • @cCubify
    @cCubify Місяць тому

    Thanks for the explanation, left a like!

  • @kaicooper9421
    @kaicooper9421 Місяць тому

    I feel attacked the way he put 'senior' in quotes. Where can I go to get a better understanding, I was kinda lost towards the end. Great video, I learned a lot though

    • @JanHesters
      @JanHesters Місяць тому

      Thank you! What is unclear? Maybe I can help you after the fact! 🙏

    • @kaicooper9421
      @kaicooper9421 Місяць тому

      @@JanHesters Maybe I just need to write a few examples and fail abit :D Thank you!

    • @JanHesters
      @JanHesters Місяць тому

      @@kaicooper9421 Let's go 🔥

  • @oluwatobilobaibuola5950
    @oluwatobilobaibuola5950 Місяць тому

    This is sweet

  • @gland_du
    @gland_du Місяць тому

    Bro your videos are just top notch. Much love from france ♥

    • @JanHesters
      @JanHesters Місяць тому

      Thank you! Really appreciate it. Did you learn something fun new?

  • @gamingwolf3385
    @gamingwolf3385 Місяць тому

    I like your content and your outfit bro continue

    • @JanHesters
      @JanHesters Місяць тому

      Thank you! 🙏 Trying out things differently.

  • @zinda__bad
    @zinda__bad Місяць тому

    good post. would be nice to see more positive examples rather than things not to do, or better yet, how to change your design/test thinking to fulfil the desideratum. appreciate that it's a lot of content to cover tho, nicely done

    • @JanHesters
      @JanHesters Місяць тому

      Will create many future videos with testing best practices. Stay tuned!

  • @denisroo
    @denisroo Місяць тому

    Nice energy and setup! 🔥

  • @Septrba
    @Septrba Місяць тому

    The number of times he said "Higher Order Component" is: 81 Which makes ~4,6 "Higher Order Component" / minute

    • @JanHesters
      @JanHesters Місяць тому

      Reminds of Daft Punk saying "Around The World" 144 times lol

  • @kaicooper9421
    @kaicooper9421 Місяць тому

    Is this the same thing as 'currying'. you might want to start a course or something to btw

    • @JanHesters
      @JanHesters Місяць тому

      A detailed video on functional programming including currying is coming soon 👍

  • @pongstr
    @pongstr Місяць тому

    ngl, i was waiting for a music video and a magic trick

    • @Leon_Andersen
      @Leon_Andersen Місяць тому

      one could argue that hocs are kind of magic haha

    • @TheMaymu
      @TheMaymu Місяць тому

      😂😂😂

    • @JanHesters
      @JanHesters Місяць тому

      @@Leon_Andersen True!

    • @JanHesters
      @JanHesters Місяць тому

      Dropping soon 🔜

  • @Leon_Andersen
    @Leon_Andersen 2 місяці тому

    so good to have the test desiderate "translated" to JavaScript!

  • @ZulluBalti
    @ZulluBalti 2 місяці тому

    came here from your blog I don't understand why it printed "y: 2012", should it be "y: 2014" (the value in parameter was 2012 + 2) or "y: 42" (as this was the result of y from previous call)

    • @JanHesters
      @JanHesters 2 місяці тому

      Let me explain to you the output of the given code step by step: 1. Initialization of the generator: When `moreNumbers(40)` is called, the generator function is initialized with `x = 40`, but no code runs yet. 2. First `next()` call: This starts the execution of the generator until the first `yield`. It prints `'x', 40` and then yields `40 + 2` (i.e., 42). The output is: { value: 42, done: false } 3. Second `next(2012)` call: This resumes the generator, passing `2012` back to it. This value is assigned to `y`. It then prints `'y', 2012` and yields `40 + 2012` (i.e., 2052). The output is: { value: 2052, done: false } 4. Third `next()` call: This resumes the generator again, but since no value is passed, `z` is `undefined`. It prints `'z', undefined` and as there are no more `yield` statements, the generator finishes. The output is: { value: undefined, done: true } The sequence of console logs from your code would look like this: - `'x', 40` - `{ value: 42, done: false }` - `'y', 2012` - `{ value: 2052, done: false }` - `'z', undefined` - `{ value: undefined, done: true }` The formatting here on YT might be weird, but you can copy paste it in a markdown file. Hope this helps!

    • @ZulluBalti
      @ZulluBalti 2 місяці тому

      @@JanHesters ahh thanks 🤟, so basically when we call next(value) it doesn't re-initialize the value of x, but assign this value to the variable that was assign to the last yield. and doing this const y = yield x + 2; // x = 40 doesn't assign the result (42) to y

  • @ihatethesensors
    @ihatethesensors 2 місяці тому

    Cool video. Not sure what a saga is though.

  • @JanHesters
    @JanHesters 2 місяці тому

    Hope you found this video helpful! What topic would you like to learn next? Drop it in the comments below and I might make a video about it Also, visit www.reactsquad.io/ now and hire your next senior React developer today!

  • @Leon_Andersen
    @Leon_Andersen 2 місяці тому

    Generators are super interesting, I am curious about the Saga video!

    • @JanHesters
      @JanHesters 2 місяці тому

      Thank you! Coming soon 🔥

  • @MCSCHNIESEN
    @MCSCHNIESEN 3 місяці тому

    Very helpful, thanks!

  • @cCubify
    @cCubify 3 місяці тому

    thanks!!!!

  • @poysa213
    @poysa213 3 місяці тому

    a react dev here, do you recommend learning react native ? just to be more valuable so any startup will choose me over the one who know only web

    • @JanHesters
      @JanHesters 2 місяці тому

      Unless you want to apply to a specific company that uses React Native, I would recommend to focus your efforts on getting very good at Vanilla React, Redux and Next.js because those are the most sought after.

    • @poysa213
      @poysa213 2 місяці тому

      @@JanHesters thanks, but i'm good at nextjs, i'm freelencing with it but i want to get a full time job at a company