Learning Redux-Saga #javascript #reactjs #redux #redux-saga

Learning Redux-Saga  #javascript #reactjs #redux #redux-saga

  • Redux-saga is a Redux middleware to handle side effects, mainly the asynchronous actions which change the state.
  • A saga is a generator function that can run asynchronous actions indefinitely like a thread in the application.
  • On the other hand, Redux-saga uses the generators which can pause, resume, and interact with the asynchronous actions by using generators.
  • Each of the following functions will return a saga effect which is an object containing instructions of what/how the action should be executed by the saga middleware.
  • takeEvery – – Resolve the effect with the result of each time that the action is received.

Redux-saga is a Redux middleware to handle side effects, mainly the asynchronous actions which change the state. A saga is a generator function that can run asynchronous actions indefinitely like a thread in the application.
Continue reading “Learning Redux-Saga #javascript #reactjs #redux #redux-saga”

What’s new in React 16.3(.0-alpha) – Bartosz Szczeciński – Medium

  • It is definitely more “user friendly” and might make your life a bit easier when all you want is simple state management without the “overhead” of Redux or MobX.The new API is accessible as React.createContext() and creates two components for us:Creation of the new context via React.createContextCalling the factory function…
  • Next step is to use the Consumer:Usage of the new context API — Context.ConsumerIf you happen to render the “Consumer” without embeding it in a corresponding “Provider”, the default value declared at createContext call will be used.Please notice some things:the consumer must have access to the same Context component — if you were to…
  • For this reason please consider Context a component — it should be created once and then exported + imported whenever neededthe new syntax uses the function as child (sometime called render prop) pattern — if you’re not familiar with this pattern I recommend reading some articles on itit is no longer required to use…
  • New life-cycle methodsThe other RFC to make it into the alpha release concerns deprecation of some life-cycle methods and introduction of one (four) new.This change aims to enforce best practices (you can read up on why those functions can be tricky in my article on life-cycle methods) which will be…
  • Instead the function should return the updated state data, or null if no update is needed:Using getDerivedStateFromProps in order to update stateThe returned value behaves similarly to current setState value — you only need to return the part of state that changes, all other values will be preserved.Things to keep in mind:Remember to init state!You…

React 16.3-alpha just hit npmjs and can be downloaded and added to your project. What are the biggest, most interesting changes? Context API was always a thing of mystery — it’s an official…
Continue reading “What’s new in React 16.3(.0-alpha) – Bartosz Szczeciński – Medium”

Learning Redux-Saga #javascript #reactjs #redux #redux-saga

Learning Redux-Saga  #javascript #reactjs #redux #redux-saga

  • Redux-saga is a Redux middleware to handle side effects, mainly the asynchronous actions which change the state.
  • A saga is a generator function that can run asynchronous actions indefinitely like a thread in the application.
  • On the other hand, Redux-saga uses the generators which can pause, resume, and interact with the asynchronous actions by using generators.
  • Each of the following functions will return a saga effect which is an object containing instructions of what/how the action should be executed by the saga middleware.
  • takeEvery – – Resolve the effect with the result of each time that the action is received.

Redux-saga is a Redux middleware to handle side effects, mainly the asynchronous actions which change the state. A saga is a generator function that can run asynchronous actions indefinitely like a thread in the application.
Continue reading “Learning Redux-Saga #javascript #reactjs #redux #redux-saga”

Taking Gatsby for a spin

Taking Gatsby for a spin  #webdev #javascript #reactjs #Flexi_IT

  • It’s not that I really need a new tool to create static sites, it’s just that every developer tweeting about Gatsby seems to think it’s the most exciting thing on the web since they learned they could combine the and tag.
  • Here are some of the important features of Gatsby: – – GatsbyJS is based on React which means that you’ll be writing almost everything in JavaScript / JSX.
  • If you already like React, you’ll most definitely enjoy creating static sites with Gatsby.
  • Gatsby comes with plugins to pull in data from several APIs, CMS systems and local files.
  • PRPL + the gatsby offline plugin mean that your site will be considered a PWA, will load insanely fast on any device and scores great in Google lighthouse.

A short write-up on Gatsby, a static site generator based on React
Continue reading “Taking Gatsby for a spin”

How to Connect your React App to a REST API – codeburst

  • Today we are going to connect this app to an existing REST API and use the fetched data to display our previously created list of contacts.Over the whole series of articles, we’re going to build a functional contact list with React:Part 1 — How to Create a React App with create-react-appPart 2 — How…
  • This way, the app fetches contacts at the startup and fills our contact list with data.PreparationsIf you don’t have the source code of the previous part ready, you can clone it from GitHub, install the dependencies and start the appgit clone contacts-managergit checkout part-2npm installnpm startThe app is now available…
  • To begin, let’s install axios: In your root directory (where your package.json is) execute the following command line:npm i -S axiosNext, open your App.js and perform the following actions:add the componentDidMount lifecycle method to the App component.import axios from the just installed packageadd the axios GET request to componentDidMount to…
  • Since it is empty, it is the initial State object with a replaced “contacts” property.Finally — Set the new StateNow that we got our data, picked the relevant parts out of it and created a “new” State object, we store it in the State of the App call, puts the “newState” object as…
  • Also, you learned that if you want to fetch data from a server at the startup of the app, you’ll do it in componentDidMount in a suitable component.You also learned, how to set State and that you can pass an object or a function to setState.Last but not least, you’ve…

In the previous parts of this series you learned how to bootstrap a new React app with create-react-app and create a list component. Today we are going to connect this app to an existing REST API and…
Continue reading “How to Connect your React App to a REST API – codeburst”

React Components Explained – codeburst

  • Something like thisimport React from ‘react’;class MyComponent extends React.Component { render () { return div This is a component /div }}class MyOtherComponent extends React.Component { render () { return ( div MyComponent / /div ) }}This way you are able to compose more complex and useful user interface for your…
  • Component’s render method return JSX which then use to create real HTML output which will be rendered in the browser.The interesting Thing about render method is that it runs every time when your component State or Props updates.
  • Let me show you a exampleimport React from ‘react’;class MyComponent extends React.Component { constructor(props) { super(props); this.state = { name: “Manoj” }; } render () { return div My name is {this.state.name} /div }}// if we render this component the output will beMy name is ManojIgnore the super(props) (out of…
  • Let’s see an example.class MyComponent extends React.Component { constructor(props) { super(props); this.state = { name: “Manoj” }; this.changeName = this.changeName.bind(this); } changeName () { this.setState({ name: “Your Name” }); } render () { return div onClick={this.changeName} My name is {this.state.name} /div }}In the above code we are telling our React…
  • You can run this code on jsFiddle here.PropsVisualise props as options that can be passed to a component to customize its functionality.For example, I have a heading component which renders a heading with subtitle.class MyHeading extends React.Component { render () { return div h1This is a heading/h1 pSubtitle/p /div }}If…

The simplest library I ever used in my life is React. As you know React is based upon component design. Everything in React is a component which makes it easy to reuse components frequently. You can…
Continue reading “React Components Explained – codeburst”

Check out React in Motion today for a steal – 50% off #Reactjs @reactionaryjs

Check out React in Motion today for a steal - 50% off  #Reactjs @reactionaryjs

  • This powerful web framework reinvents the way you create web UI, making it possible to build responsive browser-based applications with flowing, flicker-free screens.
  • The React in Motion liveVideo course gets you up and running with React just as smoothly.
  • As you work through the efficient crystal-clear tutorials from experienced React developer Zac Braddy, you’ll learn the ins and outs of React development, essential techniques for working with reactive applications, and handy code reuse techniques that will save you time and effort!
  • In this liveVideo, you’ll start with the fundamentals of React, as you build your first application.
  • You’ll learn how to set up the perfect build environment, build your own components, make asynchronous calls to third party APIs, efficiently test, debug, and then finally deploy your finished reactive applications!

Continue reading “Check out React in Motion today for a steal – 50% off #Reactjs @reactionaryjs”