Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rwu823/react-dev-memo

🍗 Don't let your pure component no pure.
https://github.com/rwu823/react-dev-memo

component debug dev memo pure react tool

Last synced: 2 months ago
JSON representation

🍗 Don't let your pure component no pure.

Awesome Lists containing this project

README

        



react-dev-memo













Don't let your pure component no pure.


Live Demo

## Screen
![demo-screen](./public/demo-screen.gif)

## Story
In these recent days, React team released a new [devtool](https://reactjs.org/blog/2019/08/15/new-react-devtools.html) version it's awesome and more efficiently but loss `highlight update` 😢. When we're developing a pure component and the one important thing is how to make sure our component is really pure. So that is why `react-dev-memo` is created.

## Installation

```sh
yarn add react-dev-memo
```
Installs without `--dev` because it's able to work on production.

## Usage

```diff
import React from 'react'
+ import devMemo from 'react-dev-memo'

- const PureComponent = ({ name, age }) =>


+ const PureComponent = ({ name, age, ...props }) =>

- export default React.memo(PureComponent, (prevProps, nextProps) => prevProps.name === nextProps.name && prevProps.age === nextProps.age)
+ export default devMemo(PureComponent, ['name', 'age'])
```

### Injected style props
And the highlighted styles inject `style` props into your component:

```diff
import devMemo from 'react-dev-memo'

- const PureComponent = () =>


+ const PureComponent = props =>

export default devMemo(PureComponent)
```

## Options

```ts
export interface DevMemoOptions {
/** display highlight */
highlight: boolean

/** display console */
console: boolean

/** set outline style */
outline: string

/** set highlight duration time */
duration: number
}
```