Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
fix immediate error on code loading of Toggles, prepare release v0.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
cellog committed Jan 20, 2017
1 parent 10a97be commit 3ce6b07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-redux-saga-router",
"version": "0.3.3",
"version": "0.3.4",
"description": "elegant powerful routing based on the simplicity of storing url as state",
"main": "lib/index.js",
"directories": {
Expand Down
6 changes: 3 additions & 3 deletions src/Toggle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ const NullComponent = (Loading, Component, ElseComponent) => {
}

export default (isActive, loaded = () => true, componentLoadingMap = {}) => {
const Scaffold = connect((state, rProps) => {
const scaffold = (state, rProps) => {
const loadedTest = !!loaded(state, rProps)
return {
...rProps,
'@@__isActive': loadedTest && !!isActive(state, rProps),
'@@__loaded': loadedTest
}
})
}

const defaults = {
component: DisplaysChildren,
Expand Down Expand Up @@ -66,7 +66,7 @@ export default (isActive, loaded = () => true, componentLoadingMap = {}) => {
lastProps.else = ElseComponent
lastProps.loadingComponent = Loading
const Switcher = NullComponent(Loading, Component, ElseComponent)
Toggle.HOC = Scaffold(Switcher)
Toggle.HOC = connect(scaffold)(Switcher)
const elseName = ElseComponent.displayName || ElseComponent.name || 'Component'
const componentName = Component.displayName || Component.name || 'Component'
const loadingName = Loading.displayName || Loading.name || 'Component'
Expand Down
3 changes: 2 additions & 1 deletion test/Toggle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ describe('Toggle', () => {
)
let Route, state // eslint-disable-line
it('should freak out if we don\'t initialize', () => {
expect(() => Toggle(() => true))
const R = Toggle(() => true)
expect(() => renderComponent(R, { component: Component, foo: 'bar' }, { week: 1 }))
.throws('call connectToggle with the connect function from react-redux to ' +
'initialize Toggle (see https://github.com/cellog/react-redux-saga-router/issues/1)')
})
Expand Down

0 comments on commit 3ce6b07

Please sign in to comment.