How to use the redux-query.connectRequest function in redux-query

To help you get started, we’ve selected a few redux-query examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redradix / redux-base-app / src / components / context / my-account / user-form-context.js View on Github external
}

const mapDispatchToProps = { storeUser, createUser, updateUser }

const mapPropsToQuery = function(props) {
  if (props.initialValues) return
  return {
    url: `/api/users/${props.id}`,
    transform: props.storeUser,
    update: {} // Disregard redux-query update methods
  }
}

const enhance = compose(
  connect(mapStateToProps, mapDispatchToProps),
  connectRequest(mapPropsToQuery)
)

UserFormContext = enhance(UserFormContext)

export default UserFormContext
github redradix / redux-base-app / src / components / context / my-account / users-list-context.js View on Github external
users: getUserListPage(state, currentPage),
    isReady: isUserListReady(state)
  }
}

const mapDispatchToProps = { storeUsers, setPageNumber }

const mapPropsToQuery = (props) => ({
  url: `/api/user/list?page=${props.currentPage}`,
  transform: props.storeUsers,
  update: {} // Disregard redux-query update methods
})

const enhance = compose(
  connect(mapStateToProps, mapDispatchToProps),
  connectRequest(mapPropsToQuery)
)

UsersListContext = enhance(UsersListContext)

export default UsersListContext