Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default () => {
const interval = useRef(null);
const timeout = useRef(null);
const [ visible, setVisible ] = useState(false);
const progress = useStoreState(state => state.progress.progress);
const continuous = useStoreState(state => state.progress.continuous);
const setProgress = useStoreActions(actions => actions.progress.setProgress);
useEffect(() => {
return () => {
timeout.current && clearTimeout(timeout.current);
interval.current && clearInterval(interval.current);
};
}, []);
useEffect(() => {
setVisible((progress || 0) > 0);
if (progress === 100) {
// @ts-ignore
timeout.current = setTimeout(() => setProgress(undefined), 500);
}
}, [ progress ]);
actionImp: Action;
actionNoPayload: Action;
thunkImp: Thunk;
reducerImp: Reducer;
nested: {
actionImp: Action;
thunkImp: Thunk;
};
}
let dispatch = useStoreDispatch();
dispatch({ type: 'FOO' });
let useStoreResult = useStoreState((state: State) => state.stateNumber);
useStoreResult + 1;
let useActionResult = useStoreActions(
(actions: Actions) => actions.actionImp,
);
useActionResult(1);
let store = useStore();
store.getState().stateString + 'world';
const typedHooks = createTypedHooks();
useStoreResult = typedHooks.useStoreState(state => state.stateNumber);
useStoreResult + 1;
useActionResult = typedHooks.useStoreActions(actions => actions.actionImp);
useActionResult(1);
dispatch = typedHooks.useStoreDispatch();
dispatch({
type: 'FOO',
export default ({ ...props }: RequiredModalProps) => {
const { addError, clearFlashes } = useStoreActions((actions: Actions) => actions.flashes);
const updateUserData = useStoreActions((actions: Actions) => actions.user.updateUserData);
const submit = ({ password }: Values, { setSubmitting }: FormikHelpers) => {
clearFlashes('account:two-factor');
disableAccountTwoFactor(password)
.then(() => {
updateUserData({ useTotp: false });
props.onDismissed();
})
.catch(error => {
console.error(error);
addError({ message: httpErrorToHuman(error), key: 'account:two-factor' });
setSubmitting(false);
});
};
const App = () => {
const loadData = useStoreActions(actions => actions.data.loadData);
const isLoading = useStoreState(state => state.data.isLoading);
const data = useStoreState(state => state.data.data);
return (
<button>Load Data</button>
);
};