mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-11-10 08:07:44 +01:00
13 lines
308 B
JavaScript
13 lines
308 B
JavaScript
|
import React, {useState} from 'react';
|
||
|
import {action} from '@storybook/addon-actions';
|
||
|
|
||
|
export function useActionState (name, initialVal) {
|
||
|
const [val, fn] = useState(initialVal);
|
||
|
const actionFn = action(name);
|
||
|
function retFn(val) {
|
||
|
actionFn(val);
|
||
|
return fn(val);
|
||
|
}
|
||
|
return [val, retFn];
|
||
|
}
|