All Projects → martynaskadisa → react-use-redux

martynaskadisa / react-use-redux

Licence: MIT license
Alternative Redux bindings with upcoming React hooks

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-use-redux

react-movies-finder
React Movies finder is a React app to search movies and series using redux, redux-thunk, React Hooks, and Material UI
Stars: ✭ 27 (-12.9%)
Mutual labels:  hooks, react-redux
React Redux Hooks Starter
React-redux boilerplate using hooks 🎣
Stars: ✭ 69 (+122.58%)
Mutual labels:  hooks, react-redux
Alldemo
🍑 2020全栈学习Demo大合集 包含最新 hooks TS 等 还有umi+dva,数据可视化等实战项目 (持续更新中)
Stars: ✭ 189 (+509.68%)
Mutual labels:  hooks, react-redux
React-Redux-Enterprise
A React-Redux boilerplate for enterprise/large scaled web applications
Stars: ✭ 77 (+148.39%)
Mutual labels:  react-redux
bottomnavigationviewex-android-binding
Xamarin.Android Binding Library for Ittianyu BottomNavigationViewEx
Stars: ✭ 25 (-19.35%)
Mutual labels:  bindings
book-fullstack-react
Fullstack React: The Complete Guide to ReactJS and Friends by Anthony Accomazzo
Stars: ✭ 100 (+222.58%)
Mutual labels:  react-redux
statery
Surprise-Free State Management! Designed for React with functional components, but can also be used with other frameworks (or no framework at all.)
Stars: ✭ 28 (-9.68%)
Mutual labels:  hooks
Docketeer
An easy-to-use GUI for Docker that allows developers to manage Docker containers and monitor crucial metrics.
Stars: ✭ 431 (+1290.32%)
Mutual labels:  react-redux
roover
🐱 A lightweight audio library for React apps.
Stars: ✭ 70 (+125.81%)
Mutual labels:  hooks
libsodium-sys-stable
Sodiumoxide's libsodium-sys crate, but that installs stable versions of libsodium.
Stars: ✭ 16 (-48.39%)
Mutual labels:  bindings
isomorphic-react-redux-saga-ssr
Isomorphic, React, Redux, Saga, Server Side rendering, Hot Module Reloading, Ducks, Code Splitting
Stars: ✭ 19 (-38.71%)
Mutual labels:  react-redux
godopy
[WIP] Python scripting for the Godot game engine
Stars: ✭ 27 (-12.9%)
Mutual labels:  bindings
coconat
🍥 StarterKit Builder for rocket-speed App creation on 🚀 React 17 + 📙 Redux 4 + 🚠 Router 5 + 📪 Webpack 5 + 🎳 Babel 7 + 📜 TypeScript 4 + 🚔 Linters 23 + 🔥 HMR 3
Stars: ✭ 95 (+206.45%)
Mutual labels:  hooks
react-redux-starter-kit
Get started with React, Redux, Webpack and eslint
Stars: ✭ 29 (-6.45%)
Mutual labels:  react-redux
react-ssr
从零搭建一个react-ssr框架 解决页面js事件 样式同构 服务器客户端路由 数据注水脱水等问题
Stars: ✭ 42 (+35.48%)
Mutual labels:  react-redux
React-Native-Showcase
Best List of Open Source / Examples / Free / Case Study & Featured Template React Native Apps
Stars: ✭ 39 (+25.81%)
Mutual labels:  react-redux
no-redux
⚛️ 🎣 Experimenting with using hooks and context instead of Redux
Stars: ✭ 79 (+154.84%)
Mutual labels:  hooks
material-ui-responsive-drawer
Material-UI responsive Drawer is a React-Redux component that uses Material-UI to create a responsive Drawer.
Stars: ✭ 44 (+41.94%)
Mutual labels:  react-redux
janetrs
Rust high level bindings for Janet
Stars: ✭ 36 (+16.13%)
Mutual labels:  bindings
redux-analysis
《学习源码整体架构系列》多篇之redux源码,前端面试高频源码,微信搜索「若川视野」关注我,长期交流学习~
Stars: ✭ 28 (-9.68%)
Mutual labels:  react-redux

react-use-redux

The wait is over, just use official react-redux package if you want hooks.

Alternative Redux bindings with React hooks.

Note: this is an experimental package. I do not recommend using this in production. You're probably better off using react-redux.

Discussion of using hooks in react-redux repo here

Installing

npm install react-use-redux

or

yarn add react-use-redux

Examples

Usage is very similar to what react-redux provides, except it uses hooks.

Firstly let's wrap our app with provider from react-use-redux:

import { StoreContext } from 'react-use-redux';

const store = configureStore(/* ... */)

const AppWithStore = () => (
  <StoreContext.Provider value={store}>
    <App />
  </StoreContext.Provider>
)

Now that we have that taken care of we can connect our functional components to Redux store:

import { createUseConnect } from 'react-use-redux'

const useConnect = createUseConnect((state) => ({ user: state.user }))

const Profile = () => {
  const { user } = useConnect()

  return (
    <div>
      <div>Name: {user.name}</div>
      <div>Surname: {user.surname}</div>
    </div>
  )
}

And that's it! Now we can use redux state in our components without hocs or render props.

API

StoreContext

React context which has two properties: Provider and Consumer. Value provided to <StoreContext.Provider /> should be an instance of Redux store. Use this as a top level wrapper of your app.

createUseConnect([mapStateToProps], [mapDispatchToProps], [mergeProps])

Hook creator which returns useConnect hook to be used inside a component. Behaviour is almost identical to connect from react-redux. useConnect returns an object of props.

mapStateToProps((state, ownProps) => object)

Called everytime when store is updated. Used to calculate props from current state.

mapDispatchToProps((dispatch, ownProps) => object)

Used to wrap dispatch over provided functions. If mapDispatchToProps is not provided, it will fallback to returning dispatch to props.

mergeProps((stateProps, dispatchProps, ownProps) => object)

Used to tweak how props should be merged, this is an advanced property. When this function is not provided left-to-right merge is applied:

(stateProps, dispatchProps, ownProps) => ({ ...stateProps, ...dispatchProps, ...ownProps })

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].