Fireship · @fireship
Solid in 100 Seconds
Uploaded May 16, 2022 · Length 2:32
Summary
solid framework tutorial: building fast uis with maximum control over reactivity in javascript.
- solid framework
- javascript framework
- reactive ui
- ui performance
- javascript performance
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
solid a declarative javascript framework
- 0:02
for building fast uis with maximum
- 0:04
control over reactivity it was created
- 0:06
by ryan carniato in 2018 and is loved by
- 0:09
developers because it's both pragmatic
- 0:11
and extremely performant on the surface
- 0:13
it shares many similarities with react
- 0:15
components are javascript functions that
- 0:17
return jsx for the ui however unlike
- 0:19
react there's no virtual dom it uses a
- 0:21
compiler more like svelt that converts
- 0:23
your code into vanilla javascript to
- 0:25
bring you as close to the dom as
- 0:26
possible the framework itself only
- 0:28
weighs 7 kilobytes and it completely
- 0:30
crushes runtime performance benchmarks
- 0:32
without the need for any extra magic or
- 0:34
weird hacks in your code but most
- 0:35
importantly it's truly reactive a
- 0:38
function component is only called once
- 0:40
which means you can do unheard of things
- 0:41
like you set interval predictably at the
- 0:44
top level data that changes or state is
- 0:46
managed with the create signal primitive
- 0:48
which returns a getter and setter the
- 0:50
framework will observe this data and
- 0:51
surgically update its exact location in
- 0:53
the dom when it changes instead of
- 0:55
re-rendering the entire component again
- 0:57
it's truly reactive to get started
- 0:59
generate a new solid project it uses
- 1:02
veet as the build tool and should look
- 1:03
very familiar if you've ever used react
- 1:05
define a component as a plain javascript
- 1:07
function now when you define the ui with
- 1:09
jsx you actually get a real dom element
- 1:12
instead of some weird framework
- 1:13
abstraction to add reactive state to a
- 1:15
component use the create signal function
- 1:17
it provides a getter and setter and
- 1:19
notice how the getter is a function this
- 1:21
allows the framework to observe the
- 1:23
current value reactively we can easily
- 1:25
create derived state by simply defining
- 1:27
another function based on the original
- 1:29
signal and it also provides a function
- 1:31
to memoize the return value or expensive
- 1:33
computations in some cases you may want
- 1:36
to run code when your data changes for
- 1:38
that createfact allows you to run side
- 1:40
effects any signals referenced in the
- 1:42
body of the function will automatically
- 1:44
be subscribed to to rerun the side
- 1:46
effect whenever the value changes solid
- 1:48
also provides on mount and on cleanup
- 1:50
functions that tap into the beginning
- 1:52
and end of the component lifecycle the
- 1:54
framework also goes out of its way to
- 1:56
make jsx more developer friendly for
- 1:58
example it has a show component to


