1.0.8 • Published 7 years ago

redux-affix v1.0.8

Weekly downloads
14
License
ISC
Repository
github
Last release
7 years ago

redux-affix

A react-redux's connect function with additional shorthand syntax.

Usage

affix behaves exactly like React-Redux's connect function when mapStateToProps and mapDispatchToProps are functions.

Pass single state key as mapStateToProps

affix('todos')

With connect:

connect(({todos}) => ({todos}))

Pass state keys as mapStateToProps

affix(['todos', 'user'])

With connect:

connect(({todos, user}) => ({todos, user}))

Pass state paths as mapStateToProps

affix({username: 'user.name', todoCount: 'todos.length'})

With connect:

connect(({todos, user}) => ({
  username: user.name,
  todoCount: todos.length
}))

Pass action creators as mapDispatchToProps

affix(mapStateToProps, {onToggleTask: toggleTask})

With connect:

connect(mapStateToProps, (dispatch) => ({
  onToggleTask(taskId) {
    return dispatch(toggleTask(taskId));
  }
}))
1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago