Advanced React Component Patterns – kentcdodds

Advanced #ReactJS Component Patterns:  by @kentcdodds #JavaScript

  • Two of my courses will be (have now been) released as part of Egghead’s annual Christmas course release celebration 🎉 One is The Beginner’s Guide to ReactJS and the other is Advanced React Component Patterns.
  • 👀The course starts with a single lesson where I implement a simple toggle component that manages its own state.
  • My hope is that by doing things this way you can quickly identify the trade-offs of the different patterns and know when each pattern would be most appropriate.The course wraps up by refactoring the toggle component to a redux component affectionately called “Rendux.” I think that you’ll be blown away…
  • This way we can easily create custom components which have access to the toggle component’s on state and the toggle helper function.There are actually six lessons dedicated to Higher Order Components in this course.
  • Hopefully with this refactor you’ll see both the power and the simplicity of the render prop pattern.The basic idea of the pattern is that rather than have the toggle component be responsible for doing anything special in the render method, we delegate that responsibility over to the user and we…

An overview of some of the patterns covered in my recently released Egghead.io course (free until Friday). NOTE: This is a cross-post from my newsletter. I publish each email two weeks after it’s…
Continue reading “Advanced React Component Patterns – kentcdodds”

Rendering a function with React – kentcdodds

  • But there are reasons for the API as it is and that’s not what we’re going over in this newsletter…With ReactSo thinking about this in the context of React:const getHomeContent = getContent(‘pages.home’)const ui = ( a href=”/about” {getHomeContent(‘nav.about’)} /a)// that’ll get you:a href=”/about”About/aSo far so good.
  • Anyway, this will break the app:const getHomeContent = getContent(‘pages.typo’)const ui = ( a href=”/about” {getHomeContent(‘nav.about’)} /a)// 💥 error 💥Again, this is happening because getContent(‘pages.typo’) will return the string {pages.typo} (to indicate that there’s no content at that path and the developer needs to fix that problem to get the content)….
  • The issue is that you can’t invoke a string but that’s what’s happening because getHomeContent is a string, not a function.A solution and a new problemSo the change I made this week makes it so when there’s no content at a given path, instead of a string, it returns a “sorta-curried”…
  • No problem.So now this wont throw an error, but we lose rendering the path if there’s no content!const getHomeContent = getContent(‘pages.typo’)const ui = ( a href=”/about” {getHomeContent(‘nav.about’)} /a)// that’ll get you:a href=”/about”/aAnd we want to make sure that we show the missing content so it’s more obvious for developers (yes…
  • Let’s rewrite the above to make this more clear:const getHomeContent = getContent(‘pages.typo’)const aboutContent = ui = a in this example is a function because the call to getContent had a typo, so we’ll never actually find content that matches the full path.

NOTE: This is a cross-post from my newsletter. I publish each email two weeks after it’s sent. Subscribe to get more content like this earlier right in your inbox! 💌 This week I was working on an…
Continue reading “Rendering a function with React – kentcdodds”

Improving the usability of your modules – kentcdodds

Improving the usability of your modules  #reactjs

  • All you have to do is use it:import getContentForFile from ‘react-i18n’const i18n = App() { return ( div h1{i18n(‘header.title’)}/h1 /div )}So that’s how it works (again, I’m sure some of you are thinking of other libs that could do this better, but please spare me the “well actually.” I’m aware…
  • const content = JSON.parse( … more stuffexport {getContentForFile as default, init}This presents a few challenges for users of the module.
  • Turns out that react-i18n actually exposed another module react-i18n/bootstrap to customize this behavior which is great, but that doesn’t resolve the problem of stuff happening if someone were to import react-i18n first.So what I did was a wrapped all side-effects in a function I exported called init(which was similar to…
  • But it’s ok now because that’s clear const messages = JSON.parse( ) // … other other stuff}// … more stuffexport {getContentForFile as default, init}So this means that anyone using the module now must call the init function, but they’re doing that on their own terms and whenever they want it…
  • However, we’re in the process of “inner sourcing” this module (and perhaps open sourcing it eventually), so folks are going to use it who use different tools and have different use cases.So, if it’s not too much work and doesn’t add too much complexity, then try to make the solution…

NOTE: This is a cross-post from my newsletter. I publish each email two weeks after it’s sent. Subscribe to get more content like this earlier right in your inbox! 💌 This last week I worked on my…
Continue reading “Improving the usability of your modules – kentcdodds”

Home automation with Raspberry Pi, Node and React

Home automation with #Raspberry Pi, Node and #reactjs  #Webdesign

  • When I woke up in morning, I already had about 100 github stars with over 50 upvotes on reddit and few of my friends gave really position feedback about it.
  • By the end of the day the stars were over 300 and suddenly they started increasing on each refresh and few minutes later, one of my co-workers told me that my project is 3rd on the Hacker News homepage.
  • By the time I write this post my Github repository has over 2500 stars, 129 forks and over 500 upvotes in the reddit posts combined.
  • The phone app is located in /phone-app folder, the server is located in /server.
  • High-power devices, such as LED strips, are powered via external (shared ground with the PI).

Viktor Kirilov’s personal blog about tech, home automation and engineering.
Continue reading “Home automation with Raspberry Pi, Node and React”

ReactJS Best Practices Q&A Unplugged with Radoslav Stankov Tickets, Wed, Aug 23, 2017 at 7:00 PM

Don’t miss #ReactJS Best Practices Unplugged with Radoslav Stankov @rstankov

  • Sorry, there are only 195 tickets of that type still available.
  • Sorry, your requested ticket quantity exceeds the number provided by your promotional code.
  • Sorry, the payment type chosen is invalid for this event.
  • Sorry, the payment type chosen is invalid for this event.
  • Sorry, the payment type chosen is invalid for this event.

Eventbrite – Minko Gechev and Mihail Mateev on behalf of Beer.js and Tech Talks presents ReactJS Best Practices Q&A Unplugged with Radoslav Stankov – Wednesday, August 23, 2017 at Puzl CowOrKing, Sofia, Sofia-city. Find event and ticket information.
Continue reading “ReactJS Best Practices Q&A Unplugged with Radoslav Stankov Tickets, Wed, Aug 23, 2017 at 7:00 PM”

React Native Interfaces with Leland Richardson

[podcast] React Native Interfaces with Leland Richardson @intelligibabble @Airbnb…

  • React Native works by presenting a consistent model for the user interface regardless of the underlying platform, and emitting a log of changes to that user interface.
  • In today’s episode, he explains how Airbnb uses React Native, how React Native works, and the future of the platform.
  • Software Engineering Daily listeners can go to weeditpodcasts.com/sed to get 20% off the first two months of audio editing and transcription services.
  • As a special offer to Software Engineering Daily listeners, get $50 toward any mattress purchase by visiting casper.com/sedaily and using codeat checkout.
  • To learn more and find out why companies like Github, DigitalOcean, and Yelp all use VividCortex to see deeper into their database performance.

Airbnb is a company that is driven by design. New user interfaces are dreamed up by designers and implemented for web, iOS, and Android. This implementation process takes a lot of resources, but it used to take even more before the company started using React Native. React Native allows Airbnb to reuse components effectively.
Continue reading “React Native Interfaces with Leland Richardson”

Home automation with Raspberry Pi, Node and React

Home automation with #RaspberryPi, #NodeJS and #ReactJS

#HackerNews

  • When I woke up in morning, I already had about 100 github stars with over 50 upvotes on reddit and few of my friends gave really position feedback about it.
  • By the end of the day the stars were over 300 and suddenly they started increasing on each refresh and few minutes later, one of my co-workers told me that my project is 3rd on the Hacker News homepage.
  • By the time I write this post my Github repository has over 2500 stars, 129 forks and over 500 upvotes in the reddit posts combined.
  • The phone app is located in /phone-app folder, the server is located in /server.
  • High-power devices, such as LED strips, are powered via external (shared ground with the PI).

Software Engineer. Car Lover. Electronics Enthusiast.
Continue reading “Home automation with Raspberry Pi, Node and React”