React Progressive Web Apps — Part 1 – Progressive Web Apps – Medium

#ReactJS Progressive #Web Apps:  by @GethylK #JavaScript

  • How to create your first PWA app and/or convert your existing app into PWA.In this example I created new React app with PWA in mind, but the idea should be quite similar if you have to convert your existing app into PWA.You need to understand the lifecycle of a SW, which…
  • Here is the code snippet from index.htmlRegister SW if browser supportsIf the above registration step was successful, then the SW file will be downloaded.
  • Well that is because SW can intercept the fetch event, and this will help if you want to cache something from the network.Updating Cache / Making network calls — Fetch eventSW listens to fetch event, and in our example since we handle only the basic case of caching only the static files,…
  • Adding your app to the Home Screen.Perfect!Step 1 above showed you the importance of SW and how it helps to make your app to be offline first.Step 2, tells you how you can run it from your virtual device.And now let us make it feel a bit more like an app,…
  • I would highly recommend you to use it to generate a report of you webpage.Here is an example of this github example.Webpack run on dev mode yarn startWebpack dev server with prod build yarn start:PRODWhen I first ran the report, the scores where much worse, and I went through the suggestions…

Progressive Web Apps(PWA) are gaining a lot of popularity these day, and with one of the updates this year (2017), the Create React App creates your project by default as PWA. If you haven’t heard of…
Continue reading “React Progressive Web Apps — Part 1 – Progressive Web Apps – Medium”

Learn JavaScript Promises by Building a Promise from Scratch

How to Easily Build Forms in @reactjs Native:  #JavaScript #Tech

  • But don’t let the fancy name or the fact that there is asynchronous code intimidate you — a Promise is just a plain old JavaScript object with special methods that allow you to execute code synchronously (it will do things in order even though there is a delay).
  • typeof new Promise((resolve, reject) = {}) === ‘object’ // trueLet me reiterate (because this is something that was difficult for me to grasp when I first learned promises), a Promise is just an object.
  • Behind the scenes, the fetch function is doing something like this.const fetch = function(url) { return new Promise((resolve, reject) = { request((error, apiResponse) = { if (error) { reject(error) } resolve(apiResponse) }) })}The fetch() function makes an http request to the server, but the client doesn’t know when the server…
  • This allows you to chain multiple then()’s since you’re returning the object itself.NOTE: In the native Promise, these then() and catch() functions actually return a new Promise themselves, but for this simple scenario, I’ve only returned this.
  • then() chain.When your asynchronous function calls resolve(apiResponse), the promise object then begins executing onResolve(apiResponse).

The block of code in the .then() waits until it receives the response from the server before it executes anything. This is called a Promise. But don’t let the fancy name or the fact that there is…
Continue reading “Learn JavaScript Promises by Building a Promise from Scratch”

Become a Professional React Developer

  • Sebastian Thrun invites you to enroll today in our new Intro to Self-Driving Cars Nanodegree program .
  • React is completely transforming Front-End Development.
  • To succeed in this program, you need to have experience with building front-end web applications with: – – You should have familiarity with the following:

React is completely transforming Front-End Development. Master this powerful UI library from Facebook with Udacity and the experts from React Training.
Continue reading “Become a Professional React Developer”

MobX (with Decorators) in create-react-app

MobX (with Decorators) in create-react-app  #MobX #ReactJS

  • If you are using create-react-app as your application boilerplate, you most likely run into the questions of how to setup MobX and how to use decorators in create-react-app.
  • After scaffolding your application with create-react-app on the command line, you can install mobx and mobx-react: – – Whereas the former is used as your state management solution, the latter is used to connect the state layer to your React view layer.
  • The current situation is that the maintainers of create-react-app are holding decorators back until Babel supports them in a stable stage: – – But what if you want to use decorators for your create-react-app + MobX application right now?
  • Fortunately there exists one sample project that already demonstrates how to use MobX with decorators in a Next.js application.
  • After showing all these different alternatives, using MobX with or without decorators in a plain React, a create-react-app or Next.js application, you have no excuse anymnore to give MobX as alternative to Redux a shot.

Everything to know about using MobX with and without decorators in a create-react-app with React. MobX doesn’t need necessarily decorators. But you can activate them by ejecting your application …
Continue reading “MobX (with Decorators) in create-react-app”

Qolzam/react-social-network – Simple Social Network with #reactjs

Qolzam/react-social-network - Simple Social Network with #reactjs

  • The React Social Network is an open source project relying on React a powerful javascript library for building the user interface.
  • In this project, I tried to show some features of react/react components as a social network.
  • For those who prefer writing code by typescript, now React Social Network support both javascript and typescript language.
  • I recommend that you get to know React before using React Social Network.
  • React Social Network has built by React components, so understanding how React fits into web development is important.

react-social-network – Simple React Social Network
Continue reading “Qolzam/react-social-network – Simple Social Network with #reactjs”

What’s New in React 16 and Fiber Explanation – EdgeCoders

Overview of new features in #ReactJS 16 & Fiber:  #Coding

  • What’s New in React 16 and Fiber ExplanationAn overview of the features and updates for the highly anticipated release for React.The update to the React core algorithm has been years in the making — it offers a ground-up rewrite for how React manages reconciliation.
  • This process is accomplished by introducing a new data structure called a “fiber” that maps to a React instance and manages the work for the instance as well as know its relationship to other fibers.
  • These images depict the old versus new rendering methods.Stack reconciliation — updates must be completed entirely before returning to main thread (credit Lin Clark)Fiber reconciliation — updates will be batched in chunks and React will manage the main thread (credit Lin Clark)React 16 will also prioritize updates by importance.
  • Pausing reconciliation work to allow the main thread to execute other necessary tasks provides a smoother interface and better perceived performance.Error HandlingErrors in React have been a little bit of mess to work with, but this is changing in version 16.
  • Note that the error boundary will only catch errors in the tree below it, but it will not recognize errors in itself.Moving forward, you’ll see robust and actionable errors like this:omg that’s nice (credit Facebook)Return multiple elements from renderYou can now return an array, but don’t forget your keys!render() { return…

The update to the React core algorithm has been years in the making — it offers a ground-up rewrite for how React manages reconciliation. React will maintain the same public API and should allow for…
Continue reading “What’s New in React 16 and Fiber Explanation – EdgeCoders”

Even Better Support for React in Flow – Flow – Medium

Even Better Support for #ReactJS in Flow:  by @calebmer #JavaScript

  • It is time to rethink how Flow models React.In Flow 0.53.0 we are changing how Flow models React and in doing this we can provide better types for higher-order components, strict typing for React children, and fixes for a host of bugs in Flow’s React support.The biggest change we are…
  • A React component in 0.53.0 looks like this:type Props = { foo: number,};type State = { bar: number,};class MyComponent extends React.ComponentProps, State { state = { bar: 42, }; render() { return this.props.foo + this.state.bar; }}When your component has no state, you only need to pass in a single type…
  • Without state your component definition would look like this:type Props = { foo: number,};class MyComponent extends React.ComponentProps { render() { return this.props.foo; }}If your component has default props then add a static defaultProps property:type Props = { foo: number,};class MyComponent extends React.ComponentProps { static defaultProps = { foo: 42, };…
  • For the React Router example above, you would type the Route component’s children as:type Props = { children: (data: { match: boolean }) = React.Node, path: string,};class Route extends React.ComponentProps { /* … */ }To learn more about typing React children read our documentation guide on the topic.The children prop…
  • Here is how you would type a simple higher-order component that injects a number prop, foo:function injectPropProps: {}( Component: React.ComponentType{ foo: number } Props,): React.ComponentTypeProps { return function WrapperComponent(props: Props) { return Component {…props} foo={42} /; };}class MyComponent extends React.Component{ a: number, b: number, foo: number,} {}const MyEnhancedComponent = injectProp(MyComponent);//…

The first version of Flow support for React was a magical implementation of React.createClass(). Since then, React has evolved significantly. It is time to rethink how Flow models React. In Flow 0.53…
Continue reading “Even Better Support for React in Flow – Flow – Medium”