Skip to content

Commit af3c2ed

Browse files
refactor(overmind-vue): improve error on using connect wrong and improve docs
1 parent d4c9fe9 commit af3c2ed

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"styled-components": "3.3.3",
5454
"tslib": "1.9.3",
5555
"vscode": "^1.1.34",
56-
"vue": "2.5.16",
56+
"vue": "2.6.10",
5757
"vue-hot-reload-api": "2.3.0",
5858
"vue-styled-components": "1.3.0",
5959
"ws": "7.0.0",

packages/node_modules/overmind-vue/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ export const createConnect = (overmind) => (...args) => {
135135
let options = args.length === 1 ? args[0] : args[1]
136136
let propsCallback = args.length === 1 ? null : args[0]
137137

138+
if (propsCallback && typeof propsCallback !== 'function') {
139+
throw new Error(
140+
`OVERMIND-VUE: When passing two arguments to "connect", the first has to be a function. You can alternatively only pass a single argument, which is the component`
141+
)
142+
}
143+
138144
return {
139145
...options,
140146
mixins: (options.mixins ? options.mixins : []).concat(

packages/overmind-website/examples/guide/usingovermindwithvue/connect.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ export const connect = createConnect(overmind)
2727
code: `
2828
import { connect } from '../overmind'
2929
30-
export default connect({})
30+
const Component = {}
31+
32+
export default connect(Component)
3133
`,
3234
},
3335
]

packages/overmind-website/examples/guide/usingovermindwithvue/connect_custom.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ export default () => [
1313
code: `
1414
import { connect } from '../overmind'
1515
16+
const Component = {}
17+
1618
export default connect(({ state, actions, effects }) => ({
1719
state: state.admin,
1820
actions: actions.admin
19-
}), {})
21+
}), Component)
2022
`,
2123
},
2224
]

0 commit comments

Comments
 (0)