A Front End Developer’s Guide to GraphQL

A Front End developer’s guide to GraphQL  #GraphlQL #ReactJS

  • In this post, we’ll walk through a couple of hands-on examples to show you how integrating GraphQL into your application will solve many pain points working with remote data.
  • On the backend, you’ll use Apollo Server to create a GraphQL server, which is a single endpoint that parses a GraphQL request and returns data.
  • You’ll connect your GraphQL server to your application with Apollo Client, a fast and flexible client that fetches, caches, and updates your data for you.
  • This common frustration no longer exists with GraphQL because the data you consume on the client is no longer coupled to an endpoint’s resource.
  • In this example, React Apollo, Apollo Client’s React integration, is binding our exchange rate query to our ExchangeRateList component.

No matter how large or small your application is, you’ll have to deal with fetching data from a remote server at some point. On the front end, this usually
Continue reading “A Front End Developer’s Guide to GraphQL”

busypeoples/IntroductionToFlow.md Last active Oct 8, 2017

  • Intended for developers interested in getting started with Flow.
  • At the end of this introduction, you should have a solid understanding of Flow and how to apply it when building an application.
  • Covers all the basics needed to get started with Flow.
  • Covers all the basic needed to get started with Flow and ReactJS.

Intended for developers interested in getting started with Flow.
At the end of this introduction, you should have a solid understanding of Flow and how to apply it when building an application.
Continue reading “busypeoples/IntroductionToFlow.md Last active Oct 8, 2017”

Props and Data Flow in ReactJS – Kenlyn Terai – Medium

Props and Data Flow in #ReactJS:  #JavaScript

  • (3) There are only two requirements that define a JavaScript function as a React component:The function accepts a single “props” object argument with dataIt returns a React elementA simple “Functional” componentThe equivalent “Class” componentWhether you declare a component as a function or a class, it must never modify its own props.
  • All React components must act like pure functions with respect to their props.
  • = BoringTo sum up what props are in React, theyAre data passed to components — values can be anything: a string, an array, functions, and so onAre immutableEnable components to become more reusableSo, if props are read-only, what place do they have in creating dynamic web applications?
  • The render() method also calls the diff algorithm which recognizes any changes in the component and logs them for batching to the “real” DOM.Credit: Tarun Sharma: “Understanding virtual DOM react js” from React DocsHere is an example from Components and Props in the React Docs.
  • This code renders “Hello, Sara” on the page:function Welcome(props) { return h1Hello, {props.name}/h1;}const element = Welcome name=”Sara” /;ReactDOM.render( element, it on CodePen.Let’s recap what happens in this example:We call ReactDOM.render() with the Welcome name=”Sara” / element.React calls the Welcome component with {name: ‘Sara’} as the props.Our Welcome component returns a h1Hello, Sara/h1 element as the result.React DOM efficiently updates the DOM to match h1Hello, Sara/h1.

ReactJS comes with a slew of new words and new definitions for existing ones. “Props” is no exception. To understand the meaning of “props” in ReactJS, I turned to the context where it is used — in…
Continue reading “Props and Data Flow in ReactJS – Kenlyn Terai – Medium”

ReactJs the simple way – Reduce boilerplate code and enjoy React

#reactjs the simple way – Reduce boilerplate code and enjoy React!

  • It contains actions to update the state, stores to hold it and a dispatcher to coordinate the changes, but the truth is that the important statement of flux is the unidirectional data flow: When the state is updated, the application is re-rendered reactively, so it is the state who rules the application.
  • Flux definition, including stores, actions and a dispatcher, usually explains the unidirectional data flow in a more complex way that it should.
  • It’s a data structure that triggers events when it is updated, and it happens to contain all the needed to add the unidirectional data flow to your app.
  • Every time the state is updated, Freezer create a new immutable object for it reusing the unmodified parts of the data tree.
  • Let’s see the code of the todo update reaction:

    You might be thinking that having the input values outside the components will re-render your whole app every time the user types.

ReactJs the simple way – Reduce boilerplate code and enjoy React
Continue reading “ReactJs the simple way – Reduce boilerplate code and enjoy React”

Optimizing React Rendering (Part 1) – Flexport Engineering

Optimizing React Rendering (Part 1)  #Reactjs #Javascript #Webdev

  • PureComponent does a shallow object comparison on the props, and since you are passing in the same object reference, shouldComponentUpdate will return false and the updated data will not be rendered.This means that if any part of your app mutates data that needs to be rendered, PureComponent puts you at risk of displaying stale data.
  • This is by far the biggest blocker because it results in incorrect UI behavior, and it is outside the control of your component.Fix: Never mutate values used as React props or state.
  • Even if some ancestor component triggers a re-render, PureParent will not re-render because neither its state or props has changed.This gotcha also leads to incorrect UI behavior, but the issue is scoped to the component itself, making it easy to fix.Fix: Extract data dependency into state or props, and update state or props when the data changes.Object copyingQ: What happens when Parent is re-rendered with an unchanged props.dataList?A: PureChild is re-rendered wastefully because filter returns a new object, which tricks PureChild into thinking that the prop has changed.This problem is triggered by calling any function that creates a new object or using an inline object literal in render.Fix: Cache your derived data calculations.
  • A: PureChild is re-rendered wastefully because arrow functions and Function.prototype.bind return new function instances, which tricks PureChild into thinking that the onClick handler has changed.Fix: Don’t use arrow functions and bind in render.
  • When those props change, PureChild will re-render wastefully.Fix: Unless you’re writing some sort of higher-order-component, don’t be lazy and be explicit about the props that you are passing.ConclusionTurns out our app is littered with every single one of these gotchas, and is especially dependent on mutation side-effects.

We migrated our web app to React almost 3 years ago, and since React performs extremely well out of the box, optimizing performance was not something we had to worry about. However, as our…
Continue reading “Optimizing React Rendering (Part 1) – Flexport Engineering”

Structuring React Components – Kacper Goliński – Medium

Structuring React Components  #javascript #reactnative #react #webdevelopment #reactjs

  • React ComponentsIn this short post, I would like to describe how to structure react components.The main idea is to have a structure that helps to build highly maintainable and scalable software and makes it easy for developers to navigate and find files.Each component has its own directory and inside it, we put all related files.
  • It will be also relatively easy to move components around or to create a separate package since all important code will be already packed up.Example componentsWe have to start with components directory which contains “global” components, used in different parts of an application.Above we can see Search / component, which is used in TopNavbar / and somewhere else in the app, that’s why both components are at the same main level.TopNavbar/ directory contains following files and directories:index.js – it contains only single line which exports TopNavbar default.
  • /TopNavbar’;TopNavbar.jsx – main component structure (layout).
  • Private components contain own tests, other private components, and styled-components.
  • Stories for react-storybook are only created for the main component not for private ones.ConclusionAt first, this structure may look complex and overcomplicated.

The main idea is to have a structure that helps to build highly maintainable and scalable software and makes it easy for developers to navigate and find files. Each component has its own directory…
Continue reading “Structuring React Components – Kacper Goliński – Medium”

Migrating from Cordova to React Native

Migrating from #Cordova to #ReactNative video tutorial:

  • Cordova and React Native are JavaScript based frameworks for building cross-platform mobile apps.
  • They differ greatly in their approach, with Cordova being embedded web view centric, and React Native being native centric.
  • React Native is just one of a growing number of frameworks for building mobile apps that are truly native after undergoing the build process.
  • This presentation provides a short introduction to both Cordova and React Native, and walks through the process of migrating an example app — a fitness activity tracker — from Cordova to React Native, highlighting strategies, tips, and gotchas along the way.
  • The presentation and full source code for the example app are available at:

Cordova and React Native are JavaScript based frameworks for building cross-platform mobile apps. They differ greatly in their approach, with Cordova being
Continue reading “Migrating from Cordova to React Native”