Why are people SO obsessed with useSignal()?

Поділитися
Вставка
  • Опубліковано 23 лют 2023
  • More about what signals are, how they work, and how you can use them in our full blog post: www.builder.io/blog/usesignal...
    #javascript #react

КОМЕНТАРІ • 146

  • @Steve8708
    @Steve8708  Рік тому +64

    Small but important correction - in these trivial examples you *can* use setCount(count => count + 1) to get around one issue I showed (assuming your code is that simple/trivial)
    In the real world this is not always an option though, the article shows better examples that demonstrate more properly: www.builder.io/blog/usesignal-is-the-future-of-web-frameworks

    • @Microphunktv-jb3kj
      @Microphunktv-jb3kj Рік тому

      extreme performance and javascript in the same sentence...
      on what kind of drugs are you on ?

    • @rand0mtv660
      @rand0mtv660 Рік тому +7

      Thank you for correcting yourself in the comment here :)

    • @stephenisienyi7726
      @stephenisienyi7726 8 місяців тому

      Great job, Steve. Greater job still for the correction. Shows sincerity.

    • @fifty-plus
      @fifty-plus 6 місяців тому

      Except you might want to not shadow the variable.

    • @user-ud8hw4gp6t
      @user-ud8hw4gp6t 3 місяці тому

      hmm the entire component doesnt need to rerender if you return it in a hook using dependencies, so wheres the difference to signals? i guess with signals you can have call the (lets say) signalhook directly without using an extra dependency, but does it work faster? i dont think so. and you cant use signals without statesand more than one component, so theres the same issue with async and statemutation

  • @pupfriend
    @pupfriend Рік тому +87

    I like React because it exercises the browser with rerenders. It's like browser calisthenics so the browser stays fit. I don't want by browser getting fat.

    • @amans6504
      @amans6504 Рік тому +8

      Rather the exercise of the memory i'd say

    • @nawfelbengherbia8302
      @nawfelbengherbia8302 Рік тому +9

      React also keeps us warm in the winter ^^

    • @nero1375
      @nero1375 Рік тому +1

      @@nawfelbengherbia8302 you mean more CPU cycles? hehehe

  • @muhammadmejanulhaque3305
    @muhammadmejanulhaque3305 Рік тому +17

    I love how you simply start the video with subtitles and finish the video without doing some unnecessary stuff. Loved the content

  • @tuttsj
    @tuttsj Рік тому +15

    I love the content you put out Steve. So concise and well presented. Keep up the awesome work 🙌🏻

  • @drizzletone9148
    @drizzletone9148 Рік тому +21

    It's funny how something that has been present in Vue for a really long time now is depicted as something revolutionary :D

    • @chuksjr.1440
      @chuksjr.1440 Рік тому

      Popularity never always means better!

    • @dominat0r3600
      @dominat0r3600 6 місяців тому

      It's been present in react long before this video, but it's popularity exploded when people realized you could do things useState can do but 40% faster

  • @alexiscalabera8314
    @alexiscalabera8314 Рік тому +10

    I tipically never comment, but damn, you present stuff that actually matters in a really easy and enjoyable manner. 5 minutes ago I didn't know or care about this, now I do and it's interesting af!

  • @ken6737
    @ken6737 Рік тому +4

    Love this content format. Simple, concise, and more importantly, it provides bite-sized information for viewers.

  • @chandragie
    @chandragie Рік тому

    Clear & simple explanation!

  • @eddyk564
    @eddyk564 Рік тому +66

    The way Solid JS should really be the norm in my opinion. React was build to deal with a UI that was constantly being updated, which is not the case with most web apps. It's odd that the React way as seen as normal and the Solid JS way is seen as revolutionary

    • @bradyfractal6653
      @bradyfractal6653 Рік тому +1

      It’s still lipstick on a pig compared to Svelte imho

    • @Corrup7ioN
      @Corrup7ioN Рік тому +10

      I used (and loved) KnockoutJS before React came out. It used a vaguely similar approach to singals which led me to always believe the whole virtual DOM diffing thing was kinda dumb, yet it was quickly accepted as being normal. KnockoutJS came out years before react and was by no means perfect, but I wish its approach was improved upon over all these years rather than largely forgotten until now.

    • @AlfieMakes
      @AlfieMakes Рік тому

      Stencil does something very similar to signals with their state decorator

    • @baxalasse
      @baxalasse Рік тому

      ​​@@bradyfractal6653 your comment should be pinned!

    • @charlesm.2604
      @charlesm.2604 Рік тому +10

      What bothers me the most is JSX.
      - It makes it real hard to do separation of concerns between UI layer and business logic.
      - Event handlers. I always wondered why they don't add a history parameter to the callback like they do with state setters. That's yet an other entry on the long list of React's inconsistencies.
      - JSX is supposed to be a HTML DSL yet you end up using more JS in your templates for some reason.
      - There is no built-in CSS DSL so you end up with bad implemented CSS-in-JS librairies and utilities CSS, the man who thought it was a good idea is a masochist.
      When a common return statement look like this how long does it takes before you start to question wether your fancy library is solving an issue or is causing a completely new problem ?
      return (
      {TodoStore.todos.map(item => (
      {item.text.replace("x", "y")}
      {item.isCompleted && (
      TodoStore.removeOne(item.id)}>
      Remove
      )}
      )
      That's why I would choose Vue over React any time, the directive-based templating.
      And I'd obviously prefer Angular at work but the lead forces us to work with React.

  • @Francois3k
    @Francois3k Рік тому +1

    Man u are the G.O.A.T. u made this topic so easy to digest. Keep up the firee content man!!!!!

  • @naranyala_dev
    @naranyala_dev Рік тому

    Very clear explanation, thank you

  • @brayancuenca6925
    @brayancuenca6925 Рік тому +1

    Keep up the great content!

  • @JosephCaburnay
    @JosephCaburnay Рік тому

    I hope you continue on liking what you do and provide us more good contents like this. Thank you so much. :)

  • @sherifsalah5563
    @sherifsalah5563 Рік тому +9

    Svelte does it out of the box

  • @mjarkk
    @mjarkk Рік тому +44

    You don't have to add count to the useEffect dependencies if you make setCount a function with count as argument setCount(count => count + 1)

    • @ajfalo-fi3721
      @ajfalo-fi3721 Рік тому

      do you even read comments before posting?

    • @peterbalogh5622
      @peterbalogh5622 Рік тому +3

      @@ajfalo-fi3721What are you talking about? @mjarkk is correct, and I didn’t see any other comments yet pointing this out. Nothing wrong with the truth being stated more than once, unless you want to hide it.

    • @ajfalo-fi3721
      @ajfalo-fi3721 Рік тому

      @@peterbalogh5622 see the pined comment from Steve

  • @150-150
    @150-150 Рік тому +3

    Hey Steve, nice video!
    What tool and method did you use to generate your subtitles? They look great!

  • @MrHauntedLollipop
    @MrHauntedLollipop Рік тому +1

    What do you mean by more code to download? Whole React gets shipped in case of SSR anyway

  • @adambickford8720
    @adambickford8720 Рік тому +2

    Straight talk: Its RxJs with training wheels. Of course its simpler, its solving a much easier problem.

  • @lionardo
    @lionardo Рік тому

    is there a sharable state management for components in qwik.js?

  • @dinaiswatching
    @dinaiswatching Рік тому +2

    Thanks again, Steve. I've fallen in love with this framework, but one thing concerns me, though. I'm quite aware of the $qwikfy function, but ideally it would be best if we had some UI qwik libraries, done in the qwik way, don't you agree?

  • @dinijalil6107
    @dinijalil6107 Рік тому +2

    Question for you since you do deep dives, and have a general interest in learning. What are your thoughts on code assessments vs take homes for assessing a candidate's talent?

    • @creamy_gavin
      @creamy_gavin Рік тому

      In my experience, having a candidate do a small home assessment and then mob/pair program with the candidate to is the best way of finding out what level they are

    • @dinijalil6107
      @dinijalil6107 Рік тому

      @@creamy_gavin Completely agree, and you get a sense of how they name, do they test, and how well they abstract and simplify the code. I wish more people like you were hiring.

  • @AmxCsifier
    @AmxCsifier Рік тому +2

    Do you have a video about svelte? I'd like to hear your insights about it

    • @AmxCsifier
      @AmxCsifier Рік тому

      @@alex-craft yeah svelte is less boilerplaty than solid + i prefer the templating of svelte over jsx. I was already accustomed to it through smarty and twig etc

  • @genechristiansomoza4931
    @genechristiansomoza4931 7 місяців тому

    How does it perform when dealing with arrays that are rendered?

  • @eyotajr
    @eyotajr Рік тому

    im a but confuse, so this signal thing is a solidJS only method ? and can we use it in react app ? 0:51 is that a solid js app or a react app ?
    is it possible to use signal in a react app ?

    • @user-mr1sr2rv1w
      @user-mr1sr2rv1w Рік тому

      Ryan Carniato, creator of Solid JS, has been on an evangelical mission to introduce the concept of signals to the javascript community, which is being adopted by a lot of other frameworks.

  • @malikrajat
    @malikrajat Рік тому

    Hello,
    can you help us with more Fine-Grained and deep discussion for signal.
    I can see quick and solid js, is more Fine-Grained Reactivity, less expensive and give fast performance.
    Why not angular so much

  • @baxalasse
    @baxalasse Рік тому +6

    Like RH says, "As enginers, we should be offended". Checkout Svelte instead.

  • @theodorosvragkos6752
    @theodorosvragkos6752 Рік тому

    It is something that we can now use with ReactJS + Vite properly?

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

    So is it better to hydrate or to dry?

  • @grinsk3ks
    @grinsk3ks Рік тому +2

    2:39 yeah vue was not forgotten =)

  • @yeargun5582
    @yeargun5582 Рік тому

    🔥🔥🔥

  • @TheSaceone
    @TheSaceone Рік тому

    angular dev here, waiting for signals :)

  • @lawrencejob
    @lawrencejob Рік тому +2

    I miss RXJS

  • @SomoeBlog
    @SomoeBlog Рік тому +2

    Ah yes, we going full circle aren't we I remember "laser beam the value directly into dom" at 2001!

  • @albiceleste101
    @albiceleste101 Рік тому +2

    I'm a freelancer, switched to Svelte this year

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

      ​@@aamorous Now I use both Svelte and Next, depends on the project
      Next probably easier due to the React ecosystem but Svelte nicer to code in

  • @AlanDanielx
    @AlanDanielx 6 місяців тому

    Can RemixJs use signals?

  • @rahiyansafin449
    @rahiyansafin449 Рік тому

    Soon Angular? What are they doing?

  • @user-mr1sr2rv1w
    @user-mr1sr2rv1w Рік тому

    You forgot to call count as a getter . . typeof count is Accessor. To access the value you need to call it:
    setCount(count() + 1)}>
    Count is {count()}

  • @michaelchen163
    @michaelchen163 Рік тому +1

    There’s no doubt that things are more performant but I don’t believe that the framework makes or breaks an app. With the sheer volume of react apps in production it’s clear to me that any performance gains from frameworks like solid likely won’t matter at the end of the day unless my use case is in the critical path of what solid is great for.

    • @2penry2
      @2penry2 Рік тому

      I Agree, It's impressive to see these new frameworks. But for me react is good enough.

  • @jacoblockwood4034
    @jacoblockwood4034 Рік тому +1

    Thanks for explaining that the hype isn't around something new--just that the rest of the JS community rediscovered the pub-sub model that has been around since the 90s lol

    • @jacoblockwood4034
      @jacoblockwood4034 Рік тому

      To be clear, I think signals are good--it's just odd that they haven't been around for longer. I wrote something of a wrapper around the DOM api at one point that utilized a construct very close in semantics to signals, but I never really maintained it since I shortly after learned about Solid.

    • @charlesm.2604
      @charlesm.2604 Рік тому +1

      Observer pattern

    • @jacoblockwood4034
      @jacoblockwood4034 Рік тому

      @@charlesm.2604 Mixed them up, thanks

  • @icarusgk
    @icarusgk Рік тому +1

    2:38 Vue was mentioned LETSGOOO, I feel it gets left out most of the time, thank you.

    • @cedi2929
      @cedi2929 Рік тому +1

      The "Vue way" is ref() correct?

    • @charlesm.2604
      @charlesm.2604 Рік тому

      ​@@cedi2929 With Vue you use Watchers, the API looks like this:
      watch(dependency, callback)
      The dependency can be any type, ref, reactive, getter function, array, etc... And the callback can be asynchronous or synchronous.

    • @icarusgk
      @icarusgk Рік тому

      @@cedi2929 Yess, ref() and reactive() are Vue's fine-grained "signals"

  • @nguyentrieu3607
    @nguyentrieu3607 Рік тому

    Dude, U should try Deepsignals, the upgraded version of Signals.

  • @hyunbinseo
    @hyunbinseo Рік тому

    There is a typo - Coutn

  • @brucearmstrong5536
    @brucearmstrong5536 Рік тому

    Angular is implementing this in it's next release v16

  • @mises1615
    @mises1615 Рік тому +2

    Who works on React that they have not had "signals" till now?

  • @xxXAsuraXxx
    @xxXAsuraXxx Рік тому +3

    svelte is the best

  • @gasparsigma
    @gasparsigma 9 місяців тому

    So it's like a useRef but it triggers a re-render of where it's used? Interesting

  • @valikonen
    @valikonen Рік тому

    This will be also part of Angular

  • @mahmudsajib8648
    @mahmudsajib8648 Рік тому

    Can we get a PAID frontend Reactjs course from you where you only teach about performance related stuffs? It will blow up the internet for sure.

  • @skl9942
    @skl9942 Рік тому +1

    Shouldnt count be a function in solid.js? "Count is {count()}"

    • @ajfalo-fi3721
      @ajfalo-fi3721 Рік тому

      Yes

    • @Steve8708
      @Steve8708  Рік тому +1

      Technically it can be {count} (only in the DOM, when used directly in JS like `const double = count() * 2` you need the parens. But I think it's more idiomatic to use {count()}

    • @skl9942
      @skl9942 Рік тому

      Oh cool, I didn't know that. Your videos are absolute golden. Thank you for the effort, its most appreciated 👍👍

  • @alexandreg.1000
    @alexandreg.1000 Рік тому

    It is so similar to what Vue does :D

  • @thegrumpydeveloper
    @thegrumpydeveloper Рік тому +3

    Hope react will take this as a signal 😂 to support this natively. Valtio is the close but not quite to supporting this type of behaviour but it really would be nice to be built in.

    • @fakenameforgoogle9168
      @fakenameforgoogle9168 Рік тому +2

      react would have to fundamentally change as a framework for that to happen which is very very unlikely

  • @user-ge2vc3rl1n
    @user-ge2vc3rl1n Рік тому

    Okay, but what does hydrate mean? You're saying that as if its a commonly used term and I've only heard it in redux.

    • @charlesm.2604
      @charlesm.2604 Рік тому +3

      Hydration basically means that instead of shipping your whole JS code in one bundle you have multiple chunks, so the browser only has to download the code for the content that's currently on the page.

    • @rand0mtv660
      @rand0mtv660 Рік тому +3

      In UI frameworks, hydration is a process where JavaScript code attaches itself to HTML that was sent from the server. It means JS doesn't need to rebuild whole UI again, but rather for example it can just attach event handlers to appropriate DOM nodes for that existing HTML (in case of React). It still has to run some code to actually do all that, but it doesn't need to rebuild the whole UI from scratch because it already exists, so hydration is less work compared to rendering full from scratch.
      What Charles M. said in his comment above is not hydration, but rather code splitting. This can be used for delayed hydration so that you only hydrate certain parts of UI when they become relevant. I think Astro does this a lot and you can tell it to only hydrate (load and run JS) for a certain part of the UI when you scroll to it for example.
      I guess in context of Redux it might be sending Redux store with existing data from server to browser and then just reuse that state on client. I'm not sure, haven't used Redux for a very long time.

    • @user-ge2vc3rl1n
      @user-ge2vc3rl1n Рік тому

      @@rand0mtv660 thanks for the responses

    • @charlesm.2604
      @charlesm.2604 Рік тому +1

      @@rand0mtv660 That's partially true. Hydration's goal is to offer the possibility of modifying a view client side that was server rendered.
      In a meta-framework, the server generates the HTML, ships it to the client and the client side takes over, hydrating the page content upon state changes.
      Those event handlers you talked about aren't explaining what hydration is, they're explaining one implementation of it.

    • @rand0mtv660
      @rand0mtv660 Рік тому +1

      @@charlesm.2604 Yeah that's why I mentioned for example it can attach event handlers. I was mostly referring to React implementation since I'm most familiar with that one. The point I tried to make is that hydration doesn't have anything to do with many smaller JS bundles (code splitting) and you can have hydration with a single monolithic JS bundle that isn't code split at all. They are two different things that don't have to be used together at all.

  • @mikopiko
    @mikopiko Рік тому +1

    The more mature qwik get, the more interested I become.

  • @himesh_89
    @himesh_89 Рік тому

    If you every create a course on React, i will be the first one to jump inm

  • @herman751
    @herman751 Рік тому

    For the interval example you can do the same in React by passing a function to setstate.

  • @dongums
    @dongums Рік тому +1

    hmmm similir with svelte

  • @TheGryphon14
    @TheGryphon14 Рік тому

    hello jQuery

  • @iamcasted
    @iamcasted Рік тому

    Who the hell updates state in react by accessing state variable directly😭😭😭😭😭😭

  • @thepetesmith
    @thepetesmith Рік тому +1

    Solid is what React should have been. I am worried that our app will start to be doggy.

  • @emmanuelolowu6768
    @emmanuelolowu6768 Рік тому

    The signal is basically like refs? I guess?

  • @fifty-plus
    @fifty-plus 6 місяців тому

    When you fix a leaky abstraction you remove the bugs and nuance that it introduced ... and React hooks are very leaky.

  • @victors16811
    @victors16811 Рік тому

    This is why I use mobx instead

  • @drastik67
    @drastik67 Рік тому

    Coutn

  • @theanswer1993
    @theanswer1993 Рік тому +1

    React is really outdated at this point.

  • @LarsRyeJeppesen
    @LarsRyeJeppesen Рік тому

    useSignal? lol

  • @zerocodefx1698
    @zerocodefx1698 Рік тому

    Jargon Thrashing is Lame

  • @namename8986
    @namename8986 8 місяців тому

    what is hydrate

  • @branquitodemunze
    @branquitodemunze Рік тому +4

    these frameworks are each time worse than before, it's such a mess, fixing issues that are wrong by design

    • @hunterwilhelm
      @hunterwilhelm Рік тому +8

      What's the right design? Wrong implies the existence of right

    • @z-aru
      @z-aru Рік тому

      @@hunterwilhelm Let's gooo, please ratio the OP