Skip to content

v6.0.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@solkimicreb solkimicreb released this 03 Oct 12:22
· 261 commits to master since this release

Breaking changes

Changed the default bundle to ES6 (from the previous ES5 one). The project uses none polyfillable ES6 Proxies, so the ES5 build was only defaulted to support older toolchains (bundler/minifier). If you use an older toolset please follow this docs section to learn how to use the older ES5 build.

create-react-app 2 and webpack 4 should both work with the ES6 build.

Features

Added sync batching for the most common task sources for better performance. This removes the necessity of following this docs section for performance upgrades. The docs section will be removed soon.

easy-state is using vanilla setState calls behind the scenes, which has a limited batching functionality at the moment. easy-state usage usually includes a lot of data manipulation, which results in multiple setState calls. To avoid multiple re-renders easy-state now has built-in synchronous batching for common task sources (timers and promises). The below example demonstrates this:

import { store, view } from 'react-easy-state'

const clock = store({ time: new Date() })

setInterval(() => {
  clock.time = new Date()
  clock.time = new Date()
}, 1000)

const Clock = view(() => <div>clock.time.toString()</div>)

easy-state v5 would render Clock two times every second, because clock.time is set two times. easy-state v6 renders clock.time once every second, because it has a synchronous batching. In general a single synchronous block of code renders components only once.

NOTE: This batching will be removed in favor of React's own batching when it is released (hopefully in React 17).