Sorry, but you either have no stories or none are selected somehow.
If the problem persists, check the browser console, or the terminal you've run Storybook from.
You need to use a plugin before using this hook.
Vue hook for mapActions
.
import { createComponent } from '@vue/composition-api';
import { useState, useGetters, useActions } from '@u3u/vue-hooks';
const Demo = createComponent({
setup() {
const state = {
...useState(['count']),
...useState('test', { count2: 'count' }),
};
const getters = {
...useGetters(['plusOne']),
...useGetters('test', ['minusOne']),
};
const actions = {
...useActions(['incrementAsync']), ...useActions('test', ['decrementAsync']), };
return {
...state,
...getters,
...actions, };
},
render() {
const { count, count2, plusOne, minusOne } = this; return (
<div>
<div>count: {count}</div>
<div>plusOne: {plusOne}</div>
<div style={{ marginTop: '10px' }}>test/count: {count2}</div>
<div style={{ marginBottom: '10px' }}>test/minusOne: {minusOne}</div>
<button onClick={() => this.incrementAsync()}>incrementAsync</button> <button onClick={() => this.decrementAsync()}> test/decrementAsync
</button>
</div>
);
},
});
function useActions(
namespace?: string,
map: Array<string> | Object<string | function>,
): Object;
The usage of the
useActions
hook is exactly the same as the usage ofmapActions
.
Please refer to the documentation of mapActions
for details.