This package has been deprecated

Author message:

Abandoned, use hooks

with-thenable-setstate

2.0.11 • Public • Published

with-thenable-setstate

HOC to add a thenable setState to your React components.

Support with PayPal Patreon ko-fi


Installation

npm i with-thenable-setstate

Usage

import * as React from 'react'
import withThenableSetState from 'with-thenable-setstate'
// `require` also works:
// const withThenableSetState = require('with-thenable-setstate')

class Foo extends React.Component {
  state = { a: 0 }

  // async/await example
  async something () {
    try {
      await this.thenableSetState({ a: 1 })
      await doSomethingElseNow()
    } catch (e) {
      // handle e
    }
  }

  // promise syntax example
  somethingElse () {
    this.thenableSetState({ a: 2 })
      .then(doSomethingElseNow)
      .catch((e) => {
        // handle e
      })
  }
}

export default withThenableSetState(Foo)

License

LICENSE

Package Sidebar

Install

npm i with-thenable-setstate

Weekly Downloads

20

Version

2.0.11

License

LGPL-3.0

Unpacked Size

14.5 kB

Total Files

4

Last publish

Collaborators

  • zacanger