Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function MyComponent() {
const token = useStore((state: State) => state.user.token);
const { login } = useActions((dispatch: Actions) => ({
login: dispatch.user.login,
}));
const { addTodo } = useActions((actions: Actions) => ({
addTodo: actions.todos.addTodo,
}));
addTodo('Install easy peasy');
const dispatch = useDispatch();
dispatch({
type: 'ADD_FOO',
payload: 'bar',
});
return (
<button> login({ username: 'foo', password: 'bar' })}>
{token || 'Log in'}
</button>
);
}