Releases: VanTanev/xstate-helpers
v2.0.0
Bring the package in line with latest XState.
BREAKING CHANGES
This package now requires xstate>=4.30.0 and @xstate/react>=3.0.0
- Update to [email protected] and @xstate/react@3 33c4544
- Remove unused useCallback dep 6e9858c
v1.2.0
Depricate useIsXStateTransitionAvailable()
in favor of the new useStateCan()
. It has the exact same API, but uses state.can(event)
under the hood. Also, it saves you a render when use event objects in by using JSON.stringify(event)
for React.useCallback()
dependencies.
export function useStateCan<
TEventType extends TEvent['type'],
TEvent extends EventObject = EventObject,
>(
service:
| Interpreter<any, any, TEvent, any>
| ActorRef<TEvent>,
event: TEventType | TEvent,
): boolean {
return useSelector<typeof service, boolean>(
service,
useCallback(
state => state.can(event),
// eslint-disable-next-line react-hooks/exhaustive-deps
[service, JSON.stringify(event)],
),
);
}
v1.1.0
New console method: XStateInspector.overrideOptions()
You can also override the inspector options from the console. For example, on some pages you might want the Inspector to run in a separate window:
// in the browser console
XStateInspector.overrideOptions({ iframe: false })
And then you can return to the default iframe behavior:
// in the browser console
XStateInspector.overrideOptions(undefined)
New prop options
for <XStateInspectLoader>
Optional. Pass options into @xstate/inspect
. For example:
import React from 'react';
import { XStateInspectLoader } from 'xstate-helpers/react/XStateInspectLoader';
const App = () => {
return (
<XStateInspectLoader options={{ url: 'https://statecharts.io/inspect', iframe: false }}>
<YourComponents />
</XStateInspectLoader>
);
};
v1.0.6
v1.0.5
v1.0.4
v1.0.3
v1.0.1
- Allow inspector options to be passed to <XStateInspectLoader> 6f8c39c
This allows you to use the new visualizer with <XStateInspectLoader>
!
import React from 'react';
import { XStateInspectLoader } from 'xstate-helpers/react/XStateInspectLoader';
const App = () => {
return (
<XStateInspectLoader options={{ url: 'https://stately.ai/viz' }}>
<YourComponents />
</XStateInspectLoader>
);
};
v1.0.1-1
v1.0.0
- [Breaking change] Remove
actorFromReducer
andmachineFromReducer
- [email protected] behaviors handle this 15d53b3 - [Breaking change]
createReactContextHelpers()
now returnsuseActor
instead ofuseService
4355192 - [Breaking change] Move to preconstruct, add multiple entry points d64e451
The most major change is that React
helpers are no longer exported from the root of the package, instead you must import them from xstate-helpers/react
. This change allows you to use xstate-helpers
in projects that do not have react as a dependency.