1.1.2 • Published 3 years ago

force2update v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

force2update

npm version npm downloads license

About

React hooks for force updating components. Force update from anywhere to those using a useForceUpdate hook with optional payload.

Install

npm

npm i force2update

Usage example

Basic

import { useForceUpdate, useForceUpdateField } from 'force2update'

function App() {


  const forceUpdate = useForceUpdate()


  let onUpdate = () => {
    
    // apply non-reactive changes.
    
    nonReactive.something = 'something updated'

    forceUpdate()

  }

  return (
    <main>
      <button onClick={onUpdate}>Force update</button>
      <DeeplyNestedComponentContainingComponent1 />
      <DeeplyNestedComponentContainingComponent2 />
    </main>
  )
}