Releases: beekai-oss/little-state-machine
Releases · beekai-oss/little-state-machine
v4.1.2
v4.1.1
v4.1.0
v4.0.2
Version 4.0.1
fix: Handle Chrome errors when cookies are disabled (#72)
Version 4.0.0-rc.2
- support strict type
You can create a global.d.ts
file to declare your GlobalState's type.
declare module 'little-state-machine' {
interface GlobalState {
yourDetail: {
name: string;
};
}
}
import * as React from 'react';
import {
createStore,
useStateMachine,
StateMachineProvider,
GlobalState,
} from 'little-state-machine';
createStore({
yourDetail: { name: '' },
});
const updateName = (state: GlobalState, payload: { name: string }) => ({
...state,
yourDetail: {
...state.yourDetail,
...payload,
},
});
const YourComponent = () => {
const { actions, state } = useStateMachine({
updateName
}));
return (
<div onClick={() => actions.updateName({ name: 'Kotaro' })}>
{state.yourDetail.name}
</div>
);
};
const App = () => (
<StateMachineProvider>
<YourComponent />
</StateMachineProvider>
);
Version 4.0.0
⭐️ Version 4.0.0
- Better TS support
- Much smaller bundle size
- Consistent and simplified API
Version 3.1.4
- fix actions with useMemo for useEffect dep
Version 4.0.0-rc.0
New
craeteStore
new config
export type StateMachineOptions = {
name: string;
middleWares: MiddleWare[];
storageType?: Storage;
};
create({
}, options: StateMachineOptions)
- Better TS support
// accept generic for global store type, and consistent actions
const { actions } = useStateMachine<GlobalStoreType>({
updateName,
updateLocaiton,
});
- Tiny 767B
Breaking Changes
syncStores
is removeduseStateMachine
removedaction
and consistently using{ actions }
- clean and simple API, removed
setStorageType
export { createStore, StateMachineProvider, useStateMachine };
Version 3.1.3
- fix the issue with session storage check which broke gatsbyjs