This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

react-einfach

1.0.1 • Public • Published

react-einfach

Write high performance React code for beginners

As you know, that there are quite a lot of pitfalls in React, unless you have much expertise. For instance, to avoid unnecessary re-render operations, to write component with shorter code.

This library aims to make sure even shitty code does not matter.

Set state with dirty check

React v16.8 introduced Hooks. It helps to write a much shorter variant of React.Component with functional components. However, in some case, you might set state with a object copy, but it triggers re-rendering of child (none pure) component.

The helper function withDirtyCheck give you a no-brain option to avoid this from happening!

Example:

const [formObject, setFormObject] = React.useState({name: '', email: ''})
setFormObject({...formObject, name: ''}) // will update state object
 
const [formObject2, setFormObjectIfDirty] = withDirtyCheck(React.useState({name: '', email: ''}))
setFormObjectIfDirty({...formObject, name: ''}) // will NOT update state object

Readme

Keywords

none

Package Sidebar

Install

npm i react-einfach

Weekly Downloads

1

Version

1.0.1

License

Apache-2.0

Unpacked Size

110 kB

Total Files

11

Last publish

Collaborators

  • stanleyxu2005