New React Redux coding style with hooks without selectors

1 min read Original article ↗

Use custom hooks instead of selectors

Daishi Kato

Press enter or click to view image in full size

Introduction

React Redux is one of popular web tech stacks. As I found React hooks so promising, I have been developing a hooks-based library for React Redux called “reactive-react-redux.”

Coding style using this library is mentally different from the official react-redux. Thanks to Proxy, developers don’t need to care about optimization, but just focus on composition of logic.

This library provides two basic hooks: useReduxState and useReduxDispatch. This article shows example code how to use them.

Preliminary

We use a tiny example in this article. The following is how our Redux store state looks like.

const state = {
items: [
{ title: 'ttt1', description: 'ddd1' },
{ title: 'ttt2', description: 'ddd2' },
{ title: 'ttt3', description: 'ddd3' },
},
};

How to useReduxState