Skip to content

Repository files navigation

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>
  )
}

About

force react component to update

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages