2.0.11 • Published 3 years ago
with-thenable-setstate v2.0.11
with-thenable-setstate
HOC to add a thenable setState to your React components.
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
2.0.11
3 years ago
2.0.10
3 years ago
2.0.9
4 years ago
2.0.8
4 years ago
2.0.7
4 years ago
2.0.6
4 years ago
2.0.5
4 years ago
2.0.4
4 years ago
2.0.3
4 years ago
2.0.2
5 years ago
2.0.1
5 years ago
2.0.0
5 years ago
1.1.3
5 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.1
5 years ago
1.0.0
6 years ago
0.4.1
6 years ago
0.4.0
6 years ago
0.3.1
6 years ago
0.3.0
6 years ago
0.2.1
6 years ago
0.1.0
6 years ago
0.0.2
6 years ago