Noah  Rowe

Noah Rowe

1596702360

You may not need Redux

If you were starting a new React project a few years ago, that almost always meant that you’d include Redux. React and Redux were thought to be one indivisible entity. When I was learning React myself I did that with the help of Stephen Grider’s excellent course Modern React with Redux. That course is a true bestseller. Nearly 200,000 students watched it since it was released. Stephen keeps it updated so that it includes the latest React features. You got it — that bestselling course on React has “Redux” in its title.

The year is now 2020 as I am writing it from a social distancing safety of my home. Quite a lot has changed in React in those few years. We now have hooks, we mostly write functional components and we now have a new and improved context API.

The big question is: Do we still need Redux?

I personally didn’t use Redux in any of project I started over the last couple of year or so. I don’t expect to use it in future either. Here’s why.

Redux was revolutionary when it appeared in 2015. It brought two big ideas to React:

  • It combined action-based model of Flux with a concept of Reducer (It is in its name: “Red” “ux” = “Red”ucer + Fl”ux”). That Action — Reducer pattern instantly gained traction among React programmers.
  • It solved an application-wide state. Let’s say we had certain data that we wanted to make available throughout the app. Before Redux the only reliable way to do that was to pass that data through props to child components… and then to their child components, and so on. Redux changed that. It allowed pieces of data to transcend the entire component hierarchy of an application without passing that data through props from one component to another. It also provided a convenient way to access and manipulate that application state from anywhere in the application.

Redux used a context API under the hood, which at the time was intended for React internal use only and was cumbersome to use.

#react #web-development #javascript

What is GEEK

Buddha Community

You may not need Redux

Reduce Redux Boilerplate Code with Redux-Actions

Redux has become one of the most popular libraries in front-end development since it was introduced by Dan Abramov and Andrew Clark in 2015. They designed it as the successor for Flux, with the support of some developer tools and a few more concepts embedded in it.

Flux is a fancy name for observer pattern further modified to support React. Both Flux and Redux consist of similar concepts like Store, Actions (events in the application). In other words, Flux is a simple JavaScript object but with some middleware like redux-thunk. It can be a function or a promise for Redux. However, Redux is a single source of truth with concepts like immutability, which improve performance. It is one of the main reasons for Redux to dominate in State Management.

Image for post

Flux vs Redux comparison source: enappd.com

Despite its advantages, some developers have found it rather challenging to deal with Redux due to the amount of boilerplate code introduced with it. And the complexity of the code seems to be another reason for the difficulty.

In this article, we will look at how to reduce the boilerplate code brought about by Actions and Reducers using Redux-Actions

#react-redux-boilerplate #react-redux #react #react-actions #redux

Jesus  Moran

Jesus Moran

1622824320

Modern Redux with Redux Toolkit

Redux Toolkit is the official, opinionated, batteries-included toolset for efficient Redux development. Mark Erikson (@acmemarke), long-time Redux maintainer and avid blogger about all things web development showed us the potential of Redux in action with an awesome demo!

Some handy links you might encounter in the video:
➡️ https://blog.isquaredsoftware.com/2021/01/context-redux-differences/
➡️ https://blog.isquaredsoftware.com/2018/11/react-redux-history-implementation/
➡️ https://github.com/immerjs/immer

  • 00:00 - Intro
  • 00:25 - Meet Mark Erikson
  • 02:57 - Is Redux dead?
  • 06:25 - Redux is a jack of all trades
  • 09:00 - What makes the Modern Redux tick? v7.1, Hooks
  • 10:43 - useSelector hook
  • 11:31 - useDispatch
  • 13:23 - What is Redux ToolKit & what does it do?
  • 15:30 - configureStore
  • 17:00 - Immer
  • 18:25 - createReducer API
  • 19:19 - createAction
  • 19:57 - createSlice
  • 23:27 - createSelector
  • 23:40 - createAsyncThunk
  • 24:40 - createEntityAdapter
  • 26:43 - Redux Toolkit safety check
  • 28:20 - Redux Toolkit: RTK Query
  • 32:57 - App Setup
  • 34:05 - App Usage
  • 35:05 - Redux Templates for Create-React-App
  • 35:40 - Coding demo time! - Redux + TypeScrypt + Vite App Example
  • 47:28 - RTK Query Overview
  • 50:05 - New “Redux Essential” Tutorial
  • 51:35 - Outro

React All-Day is a long-format stream of fun and learning with React experts, and live coding from familiar names and faces from around the React world!

Eight awesome guests covered eight exciting topics from sessions on testing, data management, full-stack frameworks to programming concepts, and more.

React Wednesdays is a weekly chat show with the best and brightest from the React world. Join us live every Wednesdays to hang out and ask questions. Learn more about the show and upcoming episodes at https://www.telerik.com/react-wednesdays.

#redux #redux

Let’s use redux in react

Redux is super simple to use. Actions are used to indicate what can be possible done to the states, reducers are used to indicate the transformation of the state, dispatch is used to execute the action and store is used to combine all together. Is it sounds like greek? let me explain in detail.

What is redux?

Redux is a state management library which can be used in React and it can be also used in Angular, Vue and even vanilla JavaScript. Apart from that Context API can be used as an alternative for Redux.

Why we need redux? can’t we use states and props? This is an additional burden.

Image for post

Let me explain, If sub component has its’ own states then it is not a problem to manage them. Then what if those data is needed for the sub component two. Then we have to do **state uplifting **and pass those data to the parent component as follows and pass them to the child component as props. Then it is still manageable.

Image for post

What if those data is needed for Component One and Component Two as well. Then we have to face the problem of **props drilling **as follows because we have to pass those data here and there using props and it become a burden.

Image for post

Then redux come to solve this issue by separating the data from components as follows.

#redux-reducer #react-redux #redux #react

Sidney  Purdy

Sidney Purdy

1593513911

Use Yup with Redux-form

I wanted to replace Joiand Redux-Form with [Yup](https://github.com/jquense/yup)and [Formik](https://github.com/jaredpalmer/formik), respectively. “Now why would you want to do that!?”, you might ask. Well let’s quickly go through the reasons for Yup and Formik.

Why Yup

  1. Much lightweight than Joi.

And this is why ‘lightweight’ is important:

_tl;dr: less code = less parse/compile + less transfer + less to decompress _source

2. Easier to parse for error messages from returned error object.

3. Much flexible to customize error messages without string manipulation shenanigans.

4. Yup shares very much similar syntax and method names with Joi, making replacing Joi an easy task.

Why Formik

See “Why not Redux-Form?


However, replacing redux-form with Formik was considered to me to be a heavier task than Joi with Yup, therefore here goes ‘your friendly’ medium article about it — the gist of making Yup plays well with redux-form.

First we create a validator function that will accepts our Yup schema later.

import { Schema } from 'yup';

const validator = <T>(schema: Schema<T>) => async formValues => {
  try {
    await schema.validate(formValues, { abortEarly: false })
    return {}
  } catch (errors) {
    return errors.inner.reduce(
      (errors, err) => ({
        ...errors,
        [err.path]: err.message
      }),
      {}
    )
  }
}

export default validator

#yup #redux-form-yup #react #redux-form #programming #redux

Learn React, Redux and Typescript in 2021 - Shopping Cart Example - Redux Basics #2

Hello! In this series we will learn how to use Redux to manage the state of your app. We will use TypeScript and ReactJS to build simple shopping cart app. My aim is to explain how you can build app with Redux in 2021 with the latest and the best patterns. We will use hooks and slices as our approach to build our store and connect Redux to our ReactJS app.

In the second episode we will discuss Redux basics, create our store, link it to ReactJS and write our first Redux slice.

▬ Contents of this video ▬▬▬▬▬▬▬▬▬▬
0:00 - Theoretical Intro to Redux
8:48 - Creating Redux store
10:22 - Adding Redux to ReactJS
12:50 - Creating our first Redux slice
18:30 - Connecting React component to Redux store with useSelector

You can find me here:

https://twitter.com/wojciech_bilick
https://medium.com/@wojciech.bilicki
https://github.com/wojciech-bilicki


ignore

web design
html
web development
css
html5
css3
es6
programming
basics
tutorial
javascript
how to make a website
responsive design tutorial
web development tutorial
media queries
website from scratch
html css
responsive website tutorial
responsive web development
web developer
how to make a responsive website
how to build a website from scratch
how to build a website
build a website
How to

#react #redux #typescript #redux