New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@xstate/react

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xstate/react - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

16

lib/index.js

@@ -24,5 +24,8 @@ "use strict";

var _a = __read(react_1.useState(machine.initialState), 2), current = _a[0], setCurrent = _a[1];
// Start the service (only once!)
var service = react_1.useMemo(function () {
return xstate_1.interpret(machine, options).onTransition(function (state) {
// Reference the service
var serviceRef = react_1.useRef(null);
// Create the service only once
// See https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily
var service = serviceRef.current ||
((serviceRef.current = xstate_1.interpret(machine, options).onTransition(function (state) {
// Update the current machine state when a transition occurs

@@ -32,8 +35,9 @@ if (state.changed) {

}
});
}, []);
// Stop the service when the component unmounts
})),
serviceRef.current);
react_1.useEffect(function () {
// Start the service when the component mounts
service.start();
return function () {
// Stop the service when the component unmounts
service.stop();

@@ -40,0 +44,0 @@ };

{
"name": "@xstate/react",
"version": "0.0.3",
"version": "0.1.0",
"description": "XState tools for React",

@@ -5,0 +5,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc