LEARN WHILE YOU POOP: Why you should learn React 🧐

Hi πŸ‘‹ I’m trying something new and need your feedback. What do you think of this as a format for a daily 2min video?

No pressure learning at 2 minutes per day.Start with WHY React all the way to a React 16.3 master in a month.
LEARN WHILE YOU POOP: Why are components so great πŸ€”

React, Vue, Angular, or whatever. Components are the future and you should learn how to think in them. Here's why πŸ‘‡

Hint: it's a lot like LEGO except you also have a 3D printer to make your own.
LEARN WHILE YOU POOP 3
How JSX makes your life easier πŸ‘‡

Some still debate it, but I love how JSX lets you get in there and get your hands dirty right with the stuff your code is meant to be outputting. Like a top chef πŸ‘©β€πŸ³ gently massaging a steak. πŸ₯©
LEARN WHILE YOU POOP 4
Your first @reactjs component πŸ’ͺ

Play with the code on @codesandboxapp πŸ‘‰ codesandbox.io/s/lpnmn7o6z

We're building towards a chat app πŸ’¬
LEARN WHILE YOU POOP 5 | Class-based React components

Functional component πŸ‘‰ class-based component. A little more overhead, but a lot more power. 🚀

Code is now on GitHub. One commit per video. github.com/Swizec/learn-w…
LEARN WHILE YOU POOP 6
Why you need both state and props 🧐

Both state and props are just JavaScript values that you use when rendering JSX. So why do you need both?

πŸ‘‡
LEARN WHILE YOU POOP 7
How stateful (declarative) rendering makes your job easy πŸ’ͺ

Your UI is an expression of state. Manipulate the state, change the UI. Never worry about the rendering.

Explained with the help of a magical make-your-face-young-again cream container.
I am not sure my explanation made as much sense as I wanted to. Explaining declarativeness is hard
LEARN WHILE YOU POOP 8 |
React event API and you πŸŽͺ

React comes with a full event API. It's great. No more memory leaks. But there's one bit that's hard πŸ‘‰`this`

Watch this and never struggle with the `this` keyword in your event callbacks ever again. 3 ways to do it :)
How do you share state between components?
We hoist state to the least common denominator, pass it down via props, and change it back up with callbacks.

Props flowπŸ„β€β™€οΈ down callbacks fly πŸ›© up | LEARN WHILE YOU POOP 9

Now with more bathroom mirror sketching πŸ˜›
How React components talk to each other | LEARN WHILE YOU POOP 10

Yesterday we said that props flow down and callbacks fly back up. Today we're putting that into practice with some code.

Tomorrow: React 16.3 context API. I'm excited

Code πŸ‘‰ github.com/Swizec/learn-w…
LEARN WHILE YOU POOP 11
#reactjs 16.3 Context API explained in 2 minutes 20 seconds 150 milliseconds

The new React 16.3 context API. Why to use it, when to use it, how to use it.
You'll never need Redux or MobX ever again. Maybe 😏

Code on GitHub πŸ‘‰Β github.com/Swizec/learn-w…
LEARN WHILE YOU POOP 12
Styling πŸ’… your React components

There are many ways to do it. Do you go CSS, do you go css-in-js, which css-in-js do you choose?

This video gives you The Goal and an overview of options.Next few days we look at those in detail
LEARN WHILE YOU POOP 13
Why, when, and how to use the style prop #cssinjs #reactjs

The style prop is great. It's there by default and it works. You should use it for one-off styling overrides or your app is gonna get unruly.

Code on GitHub πŸ‘‰ github.com/Swizec/learn-w…
LEARN WHILE YOU POOP 14
CSS Modules in 2 minutes πŸ‘Ύ

CSS Modules are not my favorite, but they're pretty much the only option when you have a bunch of existing CSS that you want to make better.

Code on GitHub πŸ‘‰github.com/Swizec/learn-w…
Why styled components πŸ’… are the best approach to styling React components

Balance between normal CSS and #cssinjs on fleek πŸ‘Œ

Code on GitHub πŸ‘‰github.com/Swizec/learn-w…
LEARN WHILE YOU POOP 16
Does the key prop still matter?

@reactjs will yell at you, if you render a list and don't give each element a unique key. But do things really break?

Code on GitHub πŸ‘‰ github.com/Swizec/learn-w…
LEARN WHILE YOU POOP 17
When and how you use #reactjs refs

You should never ever under absolutely no circumstances ever need to use direct DOM manipulation in a React component.

But when you do, refs are there to make it easy.

Code on GitHub πŸ‘‰github.com/Swizec/learn-w…
LEARN WHILE YOU POOP 18
React 16.3 Lifecycle Methods in 2 minutes

They seem absolutely crucial, but really you'll use them for loading data and not much else. Sometimes 3rd party library integration or making declarative animations.

🀘Still good to know. 🀘
LEARN WHILE YOU POOP 19
Patterns for component reuse

You build components with the linux philosophy. Do one thing and do it well. πŸ‘†Then assemble for bigger things.

Higher order components, render props, function as children, and composite components take a different approach
Higher Order Components explained in 2 minutes ⏰

Higher Order Components let you wrap any component in a new component. This lets you share functionality between different components in your app.

Code on GitHub πŸ‘‰ github.com/Swizec/learn-w…
Render props, the hot new thing ever since @ryanflorence put it in React Router

Why & How You Should Use React Render Props πŸ‘‡
They're great πŸ‘Œ

Tomorrow we compare to function-as-children πŸ˜›

You might enjoy this series as a YT playlist youtube.com/playlist?list=…
LEARN WHILE YOU POOP 22
Render prop or function as children? 🧐

Make your users happy, keep their codebase consistent, support both patterns. Here's how πŸ‘‡
LEARN WHILE YOU POOP 23
How you can use React Portals to do cool things 😎

Control any part of your app as if it was your component's own child element. Pretty neat.

Code on GitHub πŸ‘‰github.com/Swizec/learn-w…
LEARN WHILE YOU POOP 24
Handling errors with error boundaries ⚠️

When something goes wrong, React turns your whole app blank. You can fix that with error boundaries.

πŸ‘‡
LEARN WHILE YOU POOP 25
How you can choose what goes in what component? 🧐

A question everybody asks: How do I decide what's in my component? When should I split it up? How many abstractions should I build?

There's 3 guidelines you can use. πŸ‘‡
LEARN WHILE YOU POOP 26
Build simple forms with React controlled components and keep your API declarative

You might not need react-redux-form or any of that complex stuff 🀯

Code on GitHub πŸ‘‰ github.com/Swizec/learn-w…
Learn React Router in 2 minutes | LEARN WHILE YOU POOP 27

Plus a bonus lesson about polluting your low level components with context. That was painful, think ahead folks! πŸ˜…

Code on GitHub πŸ‘‰github.com/Swizec/learn-w…
Build πŸ— your components with @storybookjs | LEARN WHILE YOU POOP 28

You'll soon realize that dealing with your whole app when all you wanna do is build the perfect button is ... annoying. So build your components in isolation first.

Doubles as great documentation πŸ’ͺ
So you've built an amazing React component. It's self-contained, does great things, and you use it all over.

Now you wanna use it in other projects and give it to other people.
Time to opensource!

Opensource your React component | LEARN WHILE YOU POOP 29 πŸ‘‡
And thus concludes Module 1 of #learnwhileyoupoop – React Essentials

Here's what happens next πŸ‘‡
The past 30 videos were a teaser. They become a full video course

πŸŽ₯ Video so you get the gist
πŸ“– Full articles so you learn the details
πŸ™πŸ» Exercises so you can practice

Want it?

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Swizec Teller writing a book on software rewrites

Swizec Teller writing a book on software rewrites Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(