1.1.4 • Published 5 years ago

ts-redux-connect v1.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

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

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago