Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable */
import * as React from 'react';
import { createComponentStore, Action, action } from 'easy-peasy';
interface StoreModel {
count: number;
inc: Action;
}
interface InitialData {
count: number;
}
const useCounter = createComponentStore({
count: 0,
inc: action(state => {
state.count += 1;
}),
});
const useCounterWithInitializer = createComponentStore(
data => ({
count: data ? data.count + 1 : 0,
inc: action(state => {
state.count += 1;
}),
}),
);
function CountDisplay() {
count: number;
inc: Action;
}
interface InitialData {
count: number;
}
const useCounter = createComponentStore({
count: 0,
inc: action(state => {
state.count += 1;
}),
});
const useCounterWithInitializer = createComponentStore(
data => ({
count: data ? data.count + 1 : 0,
inc: action(state => {
state.count += 1;
}),
}),
);
function CountDisplay() {
const [state, actions] = useCounter();
return (
<>
<div>{state.count + 1}</div>
<button type="button">
+
</button>