The Future of State in React

The Future of #State in #reactjs   #javascript #developers

  • React’s new Context API will be the go-to solution for sharing state simply™️.
  • In this post, I’ll describe Context by creating a simple theme-switching component: – – Since Context won’t be live until React 16.3, I’ll be using the polyfill.
  • Creating a Context instance is as simple as calling a function with a default value .
  • Context’s has less emphasis on global state than Redux and can be used to as little or as large a scale that you’d want: just like MobX.
  • In the following snippet, I set up a React Component that manages the state that our Provider will pass to those willing to consume it: – – Consumers must be descendants of its context’s Provider for it to access the value it wants.

The days of relying on state-management libraries for non-local state are coming to a close. You wont need Redux anymore. Not even MobX. React’s new Context API will be the go-to solution for sharing state simply™️.
Continue reading “The Future of State in React”

Web Design Automation in action [] Make WebApps fast via this #API […

  • is the fastest free website maker on Earth.
  • Easy, Simple, Do it yourself (DIY) Websites.
  • / Q. Which is the fastest Website Builder?
  • / Q. How can I get an eCommerce website up and running / Q.
  • This is what to use when the other website builders are too slow, too complicated, too expensive or don’t have the features you want.

Instant Website Builder. Responsive design, Includes eCommerce, Forms and more. Create A Free Website or Landing Page Today!
Continue reading “Web Design Automation in action []

Make WebApps fast via this #API […”

The Beginner’s Guide to ReactJS – kentcdodds

  • You can find it here: weeks ago, my newsletter was an overview of the Advanced React Component Patterns course (that’s been published today!)
  • This week I’d like to talk a little bit about the other course that was published: The Beginner’s Guide to ReactJS.In the beginner’s course every lesson is an individual index.html file.
  • If you ever teach a total beginner React, make sure that you help them get a solid understanding that creating React elements is not magic and that JSX is a really simple abstraction on top of React.createElement.
  • Learn React Fundamentals and Advanced Patterns — I’m just pretty excited about the course release! Sale — Save 30% on a year subscription!ReactPrimer – React component prototyping tool that generates fully connected class component code.Partial Application Lambda Parameter Syntax for JavaScript — Awesome use of babel-macrosUsing Glitch as a UNIX command line playground — Interesting idea!Some tweets from…
  • 🧟🧟‍♂️🏹 29 Nov 2017I’m having a conversation about semicolons again️ 30 Nov 2017Next language I learn will be @reasonml 👌 3 Dec my big announcement!My @eggheadio courses have been published and are totally FREE!“Learn React Fundamentals and Advanced Patterns” 4 Dec 2017P.

The course is free forever on! Let’s talk about how it teaches even developers experienced with React ⚛️ NOTE: This is a cross-post from my newsletter. I publish each email two weeks after…
Continue reading “The Beginner’s Guide to ReactJS – kentcdodds”

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 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”