• Stars
    star
    151
  • Rank 246,057 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 4 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Debugger for React functional components. Online demo: https://meowtec.github.io/relyzer/examples/todomvc/build/

Relyzer

React functional component debugger.

Screenshot

screenshot

中文说明

https://zhuanlan.zhihu.com/p/391734514

Usage

Install packages

npm i relyzer -D

Add babel config

{
  plugins: [
    // enable only for development
+    isDevelopment ? 'module:@relyzer/babel' : null,
  ].filter(Boolean),
}

Notice that @relyzer/babel will do nothing when process.env.NODE_ENV === 'production'

Before the use, you probably need to know how Relyzer works:

In order to collect the runtime information, Relyzer uses babel to transform the functional component code, adding some hooks code into the body.

function MyComponent() {
  // relyzer will auto add some code
+  const r = useRelyzer()
  const a = useCallback()
+  r(a)
  ...
+  r()
}

React hooks could only properly run inside functional components or other hooks. So it is important to ensure that the additional code only be added and runs in real functional components.

There are two way for that purpose:

(1) Add jsdoc

Use @component or 'use relyzer' for explicitly marking the function as a component:

Add @component tag in jsdoc of your react component

/**
 * my component
+ * @component
 */
function MyComponent() {
  const [val, setVal] = useState();

  return (
    <div />
  )
}

/**
 * my component
 */
function MyComponent() {
+ 'use relyzer'
  const [val, setVal] = useState();

  return (
    <div />
  )
}

(2) Use the autoDetect option

Tell Relyzer to auto detect the components.

Relyzer will inject useRelyzer to all the functions with uppercase first letter. When useRelyzer called, it will try to check whether the function is called in the React render call stack

{
  plugins: [
    // enable only for development
+    isDevelopment ? ['module:@relyzer/babel', { autoDetect: true }] : null,
  ].filter(Boolean),
}

Install React Devtool

Make sure you have installed the latest React Devtool in Chrome or Firefox.

Start App

  1. Start the dev server and open browser page
  2. Open React Devtool
  3. Select component in the components tree viewer

More Repositories

1

Imagine

🖼️ PNG/JPEG optimization app for macOS, Windows and Linux.
TypeScript
2,627
star
2

audio-cutter

🎵 Experiential ~ Cut audio online 在线的音频剪切器
TypeScript
164
star
3

Owl-redirector

【No Longer Maintained】Chrome HTTP request redirector. Chrome 请求重定向扩展。
JavaScript
83
star
4

chrome-menufish

chrome 右键菜单,自定义搜索和分享。
HTML
49
star
5

ttyplayer.js

Play TTY record https://meowtec.github.io/ttyplayer.js/
JavaScript
37
star
6

diffani

Diff code and render to animation video
TypeScript
33
star
7

stylelint-no-px

A stylelint custom rule to ensure using rem instead of px
JavaScript
29
star
8

vite-plugin-svg-sprite

SVG sprite plugin for [vite](https://github.com/vitejs/vite)
TypeScript
27
star
9

LANSend

TypeScript
16
star
10

react-auto-classnames

JSX runtime for applying `clsx()` automatically
JavaScript
15
star
11

vite-plugin-import

Modular import plugin for vite
TypeScript
14
star
12

vscode-is-smarter

[DEPRECATED]这是一个早已失效的 sample
JavaScript
12
star
13

meoproxy

GUI HTTP/HTTPS proxy for debugging.
TypeScript
8
star
14

babel-plugin-react-binding

Two way binding sugar for React
JavaScript
8
star
15

page-navigator

分页导航生成器
Python
8
star
16

macaca-electron-test-sample-weibo

JavaScript
7
star
17

catro

HTTP proxy for NodeJS, Core of MeoProxy.
TypeScript
5
star
18

image2svg-loader

Webpack loader for transforming image to svg (with embedded base64 image tag)
JavaScript
4
star
19

vscode-semi

JavaScript
3
star
20

scape-range

js 音量控制条
JavaScript
2
star
21

babel-plugin-jsx-classnames

babel plugin for automatically adding `classnames()` to `className` attribute.
JavaScript
2
star
22

douban.fx

一款提升 http://douban.fm 使用体验的扩展
JavaScript
1
star
23

svgfontview

Preview svg font file.
JavaScript
1
star
24

eslint-plugin-react-ext

The missing rules for eslint-plugin-react
JavaScript
1
star
25

onedown

一键下载扩展
JavaScript
1
star
26

electron-renderer-node

CLI for fast script execution in electron renderer.
JavaScript
1
star
27

recrop

cropping & rectangle selection component for React
TypeScript
1
star
28

meowtec.github.io

http://meowtec.github.io/
CSS
1
star
29

chrome-bridge

Bridge between Chrome extension content scripts and the page.
JavaScript
1
star
30

meowtec

1
star