Releases: pedronauck/reworm
Releases · pedronauck/reworm
v2.0.2
Changelog
🚀 Features
- feat: add
Provider
because of suspense features - feat: add
subscribe
method
⚠️ Breaking Changes
Now you need to wrap your entire application using reworm provider!
import React from 'react'
import { Provider, create } from 'reworm'
const { get } = create({ name: 'John' })
const App = () => (
<Provider>
<div>{get(s => s.name)}</div>
</Provider>
)
Listening state changes
If you want to listen changes on your state you can use subscribe()
:
import React from 'react'
import { Provider, create } from 'reworm'
const user = create()
class App extends Component {
state = {
name: 'John'
}
componentDidMount() {
user.subscribe(name => this.setState({ name }))
user.set('Michael')
}
render() {
return <div>Hello {this.state.name}</div>
}
}
v1.0.4
v1.0.3
v1.0.2
v1.0.1
v1.0.0
Changelog
⚠️ BREAKING CHANGE
- refactor: remove context and state provider (34523c3)
Now you don't need to use the <State>
component as provider for state, just use get
, set
or selectors
on the fly wherever you want:
import React from 'react'
import { create } from 'reworm'
const { set, get } = create({ name: 'John' })
class App extends React.Component {
componentDidMount() {
set(prev => ({ name: 'Peter' + prev.name }))
}
render() {
return (
<div>{get(s => s.name)}</div>
)
}
}