ts-redux-connect
TypeScript icon, indicating that this package has built-in type declarations

1.1.4 • Public • Published

ts-redux-connect

Overview

Description

This is a lightweight implementation for typesafe use of the great library react-redux connect().

Usage

Define your store using reduxt createStore(), and create function connect() using ts-redux-connect.

// store.ts
import createConnect from 'ts-redux-connect';

const initialState = {
  name: "",
  age: 2
}

// reducer
const reducer = (state = initialState, action) => {
  return state;
}

// store
const store = createStore(reducer);

export type stateType = typeof initialState;
export const connect = createConnect<stateType>();

use connect() that was created in store.ts;

// component.ts
import {connect} from './store'

interface ComponentProps {
  name: string
}

const MyComponent = (props: ComponentProps) => {
  return <div> {props.name} </div>
}

export default connect<ComponentProps>((state,dispatch)=>{
  return {
    name: state.name
  }
})(MyComponent)

Install

$ npm install -S ts-redux-connect
or
$ yarn add ts-redux-connect

Author

wakhtn MIT

Package Sidebar

Install

npm i ts-redux-connect

Weekly Downloads

0

Version

1.1.4

License

MIT

Unpacked Size

2.49 kB

Total Files

5

Last publish

Collaborators

  • wakhtn