use-connect

1.0.2 • Public • Published

use-connect

The replacement of react-redux.connect.

Notice

This is not for long-term usage. It is used in case that you are rewrite your component in hooks and thinking:

Oh, I will just leave this connect method here and migrate the react part. I will do it later after react-redux introduce its own api.

// from
import { connect } from 'react-redux';
connect(mapStateToProps, mapDispatchToProps, mergeProps, options)(Component);
 
// to
import { useConnect } from 'use-connect';
const Component = (props) => {
  const {...} = useConnect(props, mapStateToProps, mapDispatchToProps, mergeProps);
  return ...
}
 
// or
import { useRedux } from 'use-connect';
const Component = () => {
  const [state, dispatch] = useRedux();
  return ...
}

Update react-redux@6 before use this.

Inspired by use-redux

Readme

Keywords

Package Sidebar

Install

npm i use-connect

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

7.66 kB

Total Files

8

Last publish

Collaborators

  • dancerphil