GithubHelp home page GithubHelp logo

open-source-labs / recoilize Goto Github PK

View Code? Open in Web Editor NEW
602.0 19.0 94.0 134.63 MB

A Chrome Dev tool for debugging applications built with the experimental Recoil.js state management library.

License: MIT License

JavaScript 42.64% HTML 0.30% CSS 7.73% TypeScript 49.32%
d3 google-chrome-extension react eslint javascript node typescript webpack recoil

recoilize's Introduction

Contributors chrome version npm version GitHub license PRs Welcome

A Dev Tool for Recoil Applications

Dev README - This guide supports developers interested in iterating on the project by providing essential information and guidelines for contributing and improving the project's development.


About

Typescript JavaScript React Redux RTK D3 Node Jest Testing Git HTML5 CSS3


Recoilize is a Chrome Dev Tool designed for debugging applications built with the Recoil.js state management library.

The tool records Recoil state and allows users to easily debug their applications with features such as time travel to previous states, visualization of the component graph and display of the atom selector network.


Download the Google Chrome Extension


Download Recoilize from the Chrome Store

Visit the Recoilize landing page to demo


Installation

Standard Installation:


For installation in applications using React.js, follow the instructions below.

Install Recoilize Module (only available as an npm package)

npm install recoilize

Import RecoilizeDebugger from the Recoilize module

import RecoilizeDebugger from 'recoilize';

Integrate RecoilizeDebugger as a React component within the recoil root:

import RecoilizeDebugger from 'recoilize';
import RecoilRoot from 'recoil';

const root = createRoot(document.getElementById("root"));

root.render(
  <RecoilRoot>
    <RecoilizeDebugger />
    <App />
  </RecoilRoot>,
);

Please note, Recoilize assumes that the HTML element used to inject your React application has an ID of 'root'. If it does not, the HTML element must be passed in as an attribute called 'root' to the RecoilizeDebugger component

Example:

import RecoilizeDebugger from 'recoilize';
import RecoilRoot from 'recoil';

//If your app injects on an element with ID of 'app'
const app = document.getElementById('app');

const root = createRoot(app);

root.render(
  <RecoilRoot>
    <RecoilizeDebugger root={app} />
    <App />
  </RecoilRoot>,
  app,
);


Using Next.js:

In order to integrate Next.js applications with RecoilizeDebugger, follow the example below.

//If your application uses Next.js modify the _app.js as follows
import dynamic from 'next/dynamic';
import { useEffect, useState } from 'react';
import { RecoilRoot } from 'recoil';

function MyApp({ Component, pageProps }) {

  const [root, setRoot] = useState(null)
  const RecoilizeDebugger = dynamic(
	() => {
	  return import('recoilize');
	},
	{ ssr: false}
  );

  useEffect(() => {

    if (typeof window.document !== 'undefined') {
      setRoot(document.getElementById('__next'));
    }
  }, [root]);
 
  return (
    <>
    <RecoilRoot>
      <RecoilizeDebugger root = {root}/>
      <Component {...pageProps} />
    </RecoilRoot>
    </>
  );
}


export default MyApp;


Once you have completed the steps above, open your application in Chrome, select the Recoilize Chrome extension*, refresh the page**, and you're ready to start debugging with Recoilize!


*The Chrome Extension is only supported with React applications using Recoil as state management
**note that you may need to refresh your page before the extension registers that the Recoilize npm package has been installed within the application. This is a known bug that needs to be addressed


Updates for Version 3.2.0

Manifest 3

Google is transitioning Chrome Extensions to Manifest v3. Soon, Manifest v2 will be phased out, and only extensions using Manifest v3 will be accepted and listed in the Chrome store. Because of this, one of the primary focuses for Recoilize 3.2 was to update the Chrome Extension to Manifest v3. With this update, users will still be able to utilize this amazing tool, as it has now been updated and complies with Manifest v3 requirements.


React 17 and 18 Compatibility

Recoilize is now compatible with React 17 and 18.


Support for Recoil 0.7.7

Recoilize now supports the most recent update to the Recoil library and is backwards compatible with older versions of Recoil.


Under the Hood

  • Deprecated dependencies have been updated
  • The version of React used to build the Recoilize Chrome Extension has been updated to v17
  • Increased testing coverage
  • Cleaner codebase for improved readability


Features

Atom Network

Easily visualize the relationship between atoms and selectors (the bread and butter of Recoil.js) with the use of the Atom Network.



Snapshot Comparison

Optimizing your app is key. Component rendering time can be difficult to keep track of if you have a long series of snapshots, and render time can vary depending on the browser and device used. Users can save a series of state snapshots and use it later to analyze and compare with the most up to date series.



Time Travel with ease

Users may travel through their snapshot history with the use of a slider or buttons.



Customizable Component Graph

The component graph allows users to visualize the relationship between components and how they are rendered.

Users have the ability to customize how they view the component graph. Components can be expanded or collapsed, and can also be displayed horizontally or vertically, depending on the users preference.



Performance Metrics

In 'Metrics' tab, two graphs display component render times.

The flame graph displays the time a component took to render itself, and all of its child components. The bar graph displays the individual render times of each component.


Throttle

In the settings tab, users are able to set throttle (in milliseconds) for large scale applications or any applications that changes state rapidly. The default is set at 70ms.


State Persistence

Recoilize allows the users to persist their application's state through a refresh or reload. At this time, the user is able to view the previous states in the dev tool, but cannot time travel to the states before refresh.


Additional Features

  • legend to see relationship between component graph and state
  • toggle to view raw component graph
  • filter atom/selector network relationship
  • filter snapshots by atom/selector keys



Contributors

Bren Yamaguchi [ github | linkedin ]

Saejin Kang [ github | linkedin ]

Jonathan Escamila [ github | linkedin ]

Sean Smith [ github | linkedin ]

Justin Choo [ github | linkedin ]

Anthony Lin [ github | linkedin ]

Spenser Schwartz [ github | linkedin ]

Steven Nguyen [ github | linkedin ]

Henry Taing [ github | linkedin ]

Seungho Baek [ github | linkedin ]

Aaron Yang [ github | linkedin ]

Jesus Vargas [ github | linkedin ]

Davide Molino [ github | linkedin ]

Taven Shumaker [ github | linkedin ]

Janis Hernandez [ github | linkedin ]

Jaime Baik [ github | linkedin ]

Anthony Magallanes [ github | linkedin ]

Edward Shei [ github | linkedin ]

Nathan Bargers [ github | linkedin ]

Scott Campbell [ github | linkedin ]

Steve Hong [ github | linkedin ]

Jason Lee [ github | linkedin ]

Razana Nisathar [ github | linkedin ]

Harvey Nguyen [ github | linkedin ]

Joey Ma [ github | linkedin ]

Leonard Lew [ github | linkedin ]

Victor Wang [ github | linkedin ]

Adam Allison [ github | linkedin ]

William Chu [ github | linkedin ]

Jordan Rice [ github | linkedin ]

Ryan Wallace [ github | linkedin ]

Alejandro Florez [ github | linkedin ]

Anne-lise Emig [ github | linkedin ]

Giovana De La Cruz [ github | linkedin ]

Kasey Wolff [ github | linkedin ]

back to top

recoilize's People

Contributors

aaronyang824 avatar alejandroflorez avatar allisonadam81 avatar amagalla avatar annelise08 avatar baohnguyen95 avatar brenyama avatar davidemmolino avatar giovanacdlc avatar henrytaing avatar hobaek avatar jaimebaik avatar janis-h avatar jasonleejml avatar jmodestov avatar joey-ma avatar jonescamilla avatar justinchoo93 avatar kaseywolff avatar leolew97 avatar nbargers avatar razananisathar avatar rwallie avatar skang1004 avatar smithsean17 avatar spenserschwartz avatar steven-nguyen-t avatar tavenshumaker avatar thisisscottcampbell avatar wangvwr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

recoilize's Issues

React Native Support?

Hi team,

Can this be used with React-Native, are there future plans to support RN?

Bests,

S.

Error when importing into project

Reproduction Steps

  • install and import into a project that:
    • uses babel
    • doesn't compile node_modules folder
      • i don't think this is standard in cjs projects to compile anything in node_modules, it generally accepted that modules should work without additional developer steps

Error:

import React, { useState, useEffect } from "react";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1167:16)
    at Module._compile (internal/modules/cjs/loader.js:1215:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
    at Module.load (internal/modules/cjs/loader.js:1100:32)
    at Function.Module._load (internal/modules/cjs/loader.js:962:14)
    at Module.require (internal/modules/cjs/loader.js:1140:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at eval (webpack-internal:///recoilize:1:18)
    at Object.recoilize ([REDACTED]/.next/server/pages/_app.js:441:1)
    at __webpack_require__ ([REDACTED]/.next/server/pages/_app.js:23:31)

I'd be happy to open a PR fixing the build to make it usable in common js projects, or maybe so it can be used by both mjs and cjs?

Error Installing

Attempting to install from the Chrome Web Store:

An error has occurred
Could not decode image: 'Recoilize-v2.png'

Restarting chrome did not fix, I cannot seem to install.

Versions:

Version 98.0.4758.82 (Official Build) (64-bit)
Version 98.0.4758.102 (Official Build) (64-bit)

setSelf() in atom effect produce eleaseNodesNowOnCurrentTree error

I using effect in my atom, which causing error during changing state.

type blockchainStateType = {
    name: string,
    blockchain?: IAVAILABLE_BLOCKCHAINS | undefined
}

export const blockchainState = atom<blockchainStateType>({
    key: 'currentBlockchainName',
    default: {
        name: localStorage.getItem("currentBlockchainName") || DEFAULT_BLOCKCHAIN,
        blockchain: getCurrentBlockchain()
    },
    effects: [
        ({onSet, setSelf}) => {
            onSet(newValue => {
                localStorage.setItem("currentBlockchainName", newValue.name);
                const currentBlockchain = getCurrentBlockchain();
                setSelf({
                    name: newValue.name,
                    blockchain: currentBlockchain
                })
            })
        }
    ]
})

obraz

Could someone explain me what am I doing wrong, or what could causing the issue?

works with storybook?

I cannot get it to work with storybook - just shows the "Supported only with Recoil apps with the Recoilize NPM module." message.

I have ensured I have passed it the right dom doc root id, and included the <RecoilizeDebugger component in my storybook Recoil wrapper.

Has anyone got it to work within storybook? is it supported?

Usage with next js

It doesn't seem that this lib supports SSR yet which is ok -
I have the following attempt to integrate with nextjs client side but have been unsuccessful.

Any help would be appreciated, would love to test this tool but haven't got a chance yet because of the bugs.

import { RecoilRoot } from 'recoil';
import dynamic from 'next/dynamic';

const RecoilLogger = dynamic(() => import('recoil-logger'), { ssr: false });
const Recoilize = dynamic(() => import('recoilize'), { ssr: false });

const root =
  typeof window !== 'undefined' && window?.document?.querySelector('#__next');

function MyApp({ Component, pageProps }) {
  return (
    <RecoilRoot>
      <RecoilLogger />
      <Recoilize root={root} />
      <Component {...pageProps} />
    </RecoilRoot>
  );
}

export default MyApp;

The following errors occur:

Screen Shot 2021-01-03 at 12 01 02 PM

Setup:

next: 10.0.4
recoilize: 1.0.0
OS: macOS Big Sur 11.1
node: 12.20.0 && 14.15.3

Raw State Json In DevTools

I would like to see Raw state json in Recoilize devtools. Is there an option?

Example from Redux Devtools

Screenshot 2022-04-19 at 6 20 23 PM

Blank screen on Chrome

Hi, thanks for this debugger.

This issue was previously reported #122. I am seeing the same blank screen problem, the symptom is also the same with a brief flash of the menu then completely blank.

I've tried the following but no luck

  • remove debugger from Chrome
  • restart chrome
  • add debugger and go to app
  • same problem
    "recoil": "0.7.7",
    "recoilize": "3.2.0",

On rare occasions restarting everything fixes it but it's unpredictable and can take a lot of tries.

Support for Recoil 0.1.3

I am trying to use Recoilize with Recoil version 0.1.3.

I get a blank screen in the dev tools.

I'm assuming that the latest version of Recoilize doesn't support Recoil version 0.1.3.

Any plans to support version 0.1.3, is Recoilize still being maintained?

snapshot.getDeps_UNSTABLE is not a function or its return value is not iterable

When trying to use <DebugObserver/> with "recoil": "^0.6.1", i get this error on page load.

index.js:59 Uncaught TypeError: snapshot.getDeps_UNSTABLE is not a function or its return value is not iterable
at index.js:59:1
at Array.forEach ()
at RecoilizeDebugger (index.js:58:1)
at renderWithHooks (react-dom.development.js:14985:1)
at mountIndeterminateComponent (react-dom.development.js:17811:1)
at beginWork (react-dom.development.js:19049:1)
at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
at invokeGuardedCallback (react-dom.development.js:4056:1)
at beginWork$1 (react-dom.development.js:23964:1)

TypeError: Cannot read property 'hasOwnProperty' of null

I get this error immediately after install. Install went fine following the install instructions on the readme here. This was the top error on the traceback on the response of the first run.

TypeError: Cannot read property 'hasOwnProperty' of null
createAtomsSelectorArray
S:/Projects/2077 key manager/2077keys/node_modules/recoilize/formatFiberNodes.js:37
  34 | while (currentNode) {
  35 |   // if the memoizedState has a deps key, and that deps key is an array
  36 |   // then the first value of that array will be an atom or selector
> 37 |   if (
     | ^  38 |     currentNode.hasOwnProperty('memoizedState') &&
  39 |     typeof currentNode.memoizedState === 'object' &&
  40 |     !Array.isArray(currentNode.memoizedState) &&

React 17 support

Any plans to add support to React 17?

I have an application using NextJs and it’s not possible to install Recoilize without using —force.

The state trees font size shouldn't scale

Right now the state tree is not really usable since the font size scales with the graph. Trying to get an overview is impossible, because you can't see what the dots are anymore.
Bildschirmfoto 2020-08-04 um 11 26 11

Typescript error when passing root prop to RecoilizeDebugger

Having problems setting up Recoilize in a Next.js app and typescript.

I get:
Type '{ root: any; }' is not assignable to type 'IntrinsicAttributes & { children?: ReactNode; }'. on this line:

      <RecoilizeDebugger root={root} />

The problem seems to be we are initiating root as null in this line:

 const [root, setRoot] = React.useState(null)

Here is the complete code: https://gist.github.com/matiasmm/1d87a1221e14345b1153d296e25e4bbc#file-_app-tsx-L27

Is there a workaround for this?

Recoilize shows blank screen in Chrome dev tools

Hi ,

Recoilize was working for me around 2 weeks back when I had tracked and tested Issue #107

Blank-Screen
I am using
"recoil": "0.0.13",
"recoilize": "0.9.4",

However now when testing the same App I am getting blank screen ( see attached image) . However simple Recoil Apps & Playground shows up properly. Not sure how to further debug the issue. The App which I am debugging is quite heavy and has couple of recoil atoms ..

Installation fails

I am trying to install Recoilize extension but get the error message
Image could not be decoded: "Recoilize-v2.png"

This message is translated by myself - the original message in German is:
Bild konnte nicht decodiert werden: "Recoilize-v2.png"

I tried the installation on two different computers, both running Chrome 98.0.4758.82 on Windows 10.

What can I do to install Recoilize?

Add React 18 support

Error:

Uncaught TypeError: Cannot read properties of undefined (reading '_internalRoot')

React 18.1
Recoil 0.7.3

Error with nextjs - Recolize v3.1.6

the final build of library is with modern javascript.

and use window, session storage, _reactRootContainer without validation if this exist


ERROR DATA:

node_modules/recoilize/index.js:1
import {useState, useEffect} from 'react';
^^^^^^

SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs/loader:1067:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.recoilize (/home/linuxlite/fast-admin/.next/server/pages/_app.js:119:18)
at webpack_require (/home/linuxlite/fast-admin/.next/server/webpack-runtime.js:33:42)

window is not defined

sessionStorage is not defined

cant read _reactRootContainer on null

TypeError: Cannot read properties of undefined (reading '_internalRoot')

React With single-spa

Uncaught TypeError: Cannot read properties of undefined (reading '_internalRoot')

with the function:

const createDevToolDataObject = (filteredSnapshot, diff) => {
    if (diff === undefined) {
      return {
        filteredSnapshot: filteredSnapshot,
        componentAtomTree: formatFiberNodes(
          recoilizeRoot._reactRootContainer._internalRoot.current,
        ),
      };
    } else {
      return {
        filteredSnapshot: filteredSnapshot,
        componentAtomTree: formatFiberNodes(
          recoilizeRoot._reactRootContainer._internalRoot.current,
        ),
        indexDiff: diff,
      };
    }
  };

same issue with

Originally posted by @adamdaly in #136 (comment)

support for atomFamily

Problem

As a user, I want to be able to see atomFamily states.

Solution

The only solution for now is for me to use atom() and create the underlying structure myself. It adds complexity for setting/retrieving the values.

Additional information

No response

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd love to make a PR to implement this feature!

index.js:201 Uncaught TypeError: Cannot read properties of undefined (reading '_internalRoot') at createDevToolDataObject (index.js:201:1)

I just install recoilize to chrome
https://chrome.google.com/webstore/detail/recoilize/jhfmmdhbinleghabnblahfjfalfgidik

and install the npm package "recoilize": "^3.1.6",

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
  <StrictMode>
    <RecoilRoot>
      <RecoilizeDebugger />
      ....SOME OTHE COMPONENTS
    </RecoilRoot>
  </StrictMode>
);

and I get this error:

index.js:201 Uncaught TypeError: Cannot read properties of undefined (reading '_internalRoot')
    at createDevToolDataObject (index.js:201:1)
    at index.js:98:1
    at commitHookEffectListMount (react-dom.development.js:23150:1)
    at commitPassiveMountOnFiber (react-dom.development.js:24926:1)
    at commitPassiveMountEffects_complete (react-dom.development.js:24891:1)
    at commitPassiveMountEffects_begin (react-dom.development.js:24878:1)
    at commitPassiveMountEffects (react-dom.development.js:24866:1)
    at flushPassiveEffectsImpl (react-dom.development.js:27039:1)
    at flushPassiveEffects (react-dom.development.js:26984:1)
    at react-dom.development.js:26769:1

For some reason _reactRootContainer is not define recoilizeRoot._reactRootContainer

  const createDevToolDataObject = (filteredSnapshot, diff, atomsAndSelectors) => {
    if (diff === undefined) {
      return {
        filteredSnapshot: filteredSnapshot,
        componentAtomTree: formatFiberNodes(
          recoilizeRoot._reactRootContainer._internalRoot.current,
        ),
        atomsAndSelectors,
      };
    } else {
      return {
        filteredSnapshot: filteredSnapshot,
        componentAtomTree: formatFiberNodes(
          recoilizeRoot._reactRootContainer._internalRoot.current,
        ),
        indexDiff: diff,
        atomsAndSelectors,
      };
    }
  };

Using the debugger slows the app down massively

Sorry for this issue bombardment, but I really like the idea behind this project and want help out.

Using this Debugger in a medium sized app considerable slows it down. Not quite sure yet, why this is happening. I will try to get a minimal repro working.

extension crash on boot using RecoilizeDebugger

Recoil crashes immediately and chrome extension fails (needs to be reloaded).

import { RecoilRoot } from 'recoil';
import RecoilizeDebugger from 'recoilize';

...

<React.StrictMode>
<RecoilRoot>
        <RecoilizeDebugger/>
        <App />
</RecoilRoot>
</React.StrictMode>

Screen Shot 2021-09-22 at 3 30 21 PM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.