npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-xstate-floating-inspect

v1.0.4

Published

xstate inspector in a floating window

Downloads

2

Readme

react-native-xstate-floating-inspect

Inspect your V5 xstate machines using an In-App inspector

See the Demo App for reference implementation

Add the package to your dependencies

$ npm install react-native-xstate-floating-inspect

Usage

There are two ways to use this tool. You can either construct your own inspector using our hook, or you can use our Context Provider which will make the inspector available to your entire app. Only a single instance can be alive at a given time, so pick the use case that works best for you.

Once you create the inspector, be sure to render the floating window near the root of your view hierarchy

Create a single use Inspector

import {
  FloatingInspector,
  useFloatingXStateInspector,
} from "react-native-xstate-floating-inspect";

const Component = () => {
  const inspector = useXStateInspectorDevTool();
  const [state, send] = useMachine(machine, {
    inspect: inspector?.inspect,
  });

  const [isFloatingVisible, setIsFloatingVisible] = useState(true);

  return (
    <>
        ...
        {isFloatingVisible && (
            <FloatingInspector onClosePress={() => setIsFloatingVisible(false)} />
        )}
    </>
  )
}

Use Provided Inspector from Context

First, create a Provider that will internally create the inspector.

import { FloatingXStateInspectorProvider } from 'react-native-xstate-floating-inspect';

const App = () => (
    <FloatingXStateInspectorProvider>
        {/* rest of app */}
        <FloatingInspector onClosePress={() => setIsFloatingVisible(false)} />
    </FloatingXStateInspectorProvider>
);

Then in a component where you have a machine, grab the inspector using this hook.

import { useProvidedXstateFloatingInspector } from 'react-native-xstate-floating-inspect';

 const inspector = useProvidedXstateFloatingInspector();
  const [state, send] = useMachine(audioMachine, {
    inspect: inspector?.inspect,
  });

This uses the already created inspector in the Context. It is null for production builds.

Troubleshooting

Compilation issue - Cannot find EventTarget

The error looks like this...

ERROR  
  PartySocket requires a global 'EventTarget' class to be available!
  You can polyfill this global by adding this to your code before any partysocket imports: 
  
  import 'partysocket/event-target-polyfill';

Instead of using this polyfill, we can install 'event-target-shim' and then polyfill it.

import { EventTarget, Event } from 'event-target-shim';
global.EventTarget = EventTarget;
global.Event = Event;