All Versions
173
Latest Version
Avg Release Cycle
27 days
Latest Release
1253 days ago
Changelog History
Page 5
Changelog History
Page 5
-
v5.0.1 Changes
- π Fixed regression bug:
ObservableMap.size
was no longer observable. Fixes #1583 - β¬οΈ Downgraded lib export from ES6 to ES5. To many build tools still trip over ES6. Fixes #1584. A modern build is available through
import ... from "mobx/lib/mobx.es6"
(or setup an alias in your build system) - π Added support for mobx-react-devtools
- π Fixed regression bug:
-
v5.0.0 Changes
π Release blogpost
π Proxy support!
MobX 5 is the first MobX version fully leveraging Proxies. This has two big advantages
- MobX can now detect the addition of properties on plain observable objects, so it is now possible to use plain observable objects as dynamic collections.
- Observable arrays are now recognized as arrays by all third party libraries, which will avoid the need to slice them.
The system requirements to run MobX has been upped
- π MobX 5 can only be used on environments that support
Proxies
. See the browser support for details. - β¬οΈ Since MobX no longer runs on older browsers, the compilation target has been upgraded to ES2015 syntax supporting browsers. This means that MobX is not loadable on older browsers without down compilation to ES5.
- If for whatever reason your project cannot meet this requirements, please stick to MobX 4. It will be actively maintained. All current features of MobX 5 are expressable in MobX 4 as well, but it means that for example to use dynamic objects some additional APIs are needed.
- π The performance footprint of MobX 5 should be pretty similar to MobX 4. In our performance tests we saw some minor improvements in memory footprint, but overall it should be pretty comparable.
π₯ Breaking changes
- π The required runtime needs to support the non-polyfillable
Proxy
API. - The minimum runtime target is now ES2015, not ES5
- π
spy
has become a no-op in production builds - β¬οΈ All earlier deprecated APIs are dropped. Make sure to not have any deprecation warnings before upgrading.
- π
array.move
andarray.peek
are removed from the API - Dropped the third argument to
array.find
andarray.findIndex
since they were not standardized in ES. -
.$mobx
property has been dropped from all observables and replaced by a Symbol. Instead of usingx.$mobx.name
, useimport { $mobx } from "mobx"; x[$mobx].name
etc. - In some cases, the order in which autoruns are fired could have changed due to some internal optimizations (note that MobX never had a guarantee about the order in which autoruns fired!)
π New features
- π It is possible to pass the
proxy: false
argument toobservable.object
to disable proxying (theoretically slightly faster, but removes no dynamic key addition)
Known Issues
- π
Observable objects can no longer be frozen (otherwise they would become un-observableπ). If you are actually trying to do so MobX will now throw an exception like:
[mobx] Dynamic observable objects cannot be frozen]
. A place where that might happen unexpectedly is when passing an observable object asstyle
property to a React component. Like<span style={someObservableObject} />
, since React will freeze all style objects. The work-around is to simply pass a fresh, non-observable object for styling like:<span style={{...someObservableObject}} />
. - β¬οΈ
If you are usingFixed in mobx-react 5.2.1. But note that you should still migrate away frommobx
withmobx-react
, and you are upgradingmobx-react
to the MobX 5 compatible version ([email protected]
) you will notice thatthis.props
orthis.state
are not yet observable in theconstructor
orcomponentWillMount
. This is for forward compatibility with React 16.3 wherecomponentWillMount
has been deprecated. In most cases usingcomponentDidMount
instead will suffice, especially when the goal is to setup reactions. For more info see #478.componentWillMount
π. - βͺ Jest
toEqual
might throw an errorallKeys[x].match is not a function
when trying to equal observable arrays. This is a bug in Jest report. The simple work around for now is to slice (ortoJS
if the problem is recursive) the array first. - βͺ Jest
toEqual
matcher might no longer correctly equal your class instances, complaining about differences in the MobX adminstration. This is due to a bug with the processing of symbols: report. For now you might want to use a custom matcher if you are directly equalling observable objects. As a work aroundtoJS(object)
could be used before diffing.
Note June 7th, 2018: Both issues are already in Jest master and should be released soon.
Migration guide
- π Make sure to not use any API that produces deprecation warnings in MobX 4. Beyond that MobX 5 should pretty well as drop-in replacement of MobX 4.
- You could perform the following clean ups:
- Don't
slice()
arrays when passing them to external libraries. (Note you still shouldn't pass observable data structures to non-observer
React components, which is an orthogonal concept) - You could replace observable maps with observable objects if you are only using string-based keys.
- Don't
- π Don't call the
reverse
orsort
operations directly on observableArray's anymore, as it's behavior slightly differed from the built-in implementations of those methods. Instead useobservableArray.slice().sort()
to perform the sort on a copy. This gives no additional performance overhead compared to MobX 4. (The reason behind this is that built-insort
updates the array in place, but the observable array implementation always performed the sort on a defensive copy, and this change makes that explicit). - π you may remove usages of
isArrayLike()
sinceArray.isArray()
will now return true for observable arrays
API's that have been dropped
- π§ The
arrayBuffer
setting is no longer supported byconfigure
(it has become irrelevant) - π
observable.shallowBox
,observable.shallowArray
,observable.shallowMap
,observable.shallowObject
,extendShallowObservable
api's have been removed. Instead, pass{ deep: false }
to their non-shallow counter parts. - π
observableArray.peek
,observableArray.move
-
v4.15.7
September 19, 2020 -
v4.15.6
August 17, 2020 -
v4.15.5
August 05, 2020 -
v4.15.4
January 28, 2020 -
v4.15.3
January 24, 2020 -
v4.15.2
January 13, 2020 -
v4.15.1
December 14, 2019 -
v4.15.0
November 07, 2019