UNPKG

20.3 kBMarkdownView Raw
1# MobX-React Changelog
2
3### 5.4.0
4
5* Added support for forward refs, fixes [#602](https://github.com/mobxjs/mobx-react/issues/602)
6
7### 5.3.6
8
9* Fixed some additional issues around life-cycle patching, take 3. See [#536](https://github.com/mobxjs/mobx-react/pull/586) by [@xaviergonz](https://github.com/xaviergonz). Fixed [#579](https://github.com/mobxjs/mobx-react/issues/579)
10
11
12### 5.3.5
13
14* Fixed some additional issues around life-cycle patching, see [#583](https://github.com/mobxjs/mobx-react/pull/583) by [@xaviergonz](https://github.com/xaviergonz). Fixed [#581](https://github.com/mobxjs/mobx-react/issues/581)
15
16### 5.3.4
17
18* Fixed unending recursing as a result of lifecylce patching. Fixes [#579](https://github.com/mobxjs/mobx-react/issues/579) through [#582](https://github.com/mobxjs/mobx-react/pull/582) by [@xaviergonz](https://github.com/xaviergonz)
19
20### 5.3.3
21
22* Fixed `Cannot read property 'forEach' of undefined` exception if `disposeOnUnmount` was called conditionally. [#578](https://github.com/mobxjs/mobx-react/pull/578) by [Jef Hellemans](https://github.com/JefHellemans)
23
24### 5.3.2
25
26* Fixed: "process not defined", [#574](https://github.com/mobxjs/mobx-react/pull/574/) through [#576](https://github.com/mobxjs/mobx-react/pull/576/) by [@xaviergonz](https://github.com/xaviergonz)
27
28### 5.3.0 / 5.3.1
29
30_5.3.0 was retracted as files were not generated correctly during publish_
31
32* Added `disposeOnUnmount` utility / decorator to call disposable properties (reaction, autorun, etc) automatically on `componentWillUnmount`
33* Introduced new method to patch lifecycle methods which should be more compatible with for example arrow functions.
34
35
36### 5.2.8
37
38* Make sure `mobx-react` doesn't require `Object.assign` polyfill
39
40### 5.2.7
41
42* Fixed issue where React 16.5 printed a warning when using `Provider`, fixes [#545](https://github.com/mobxjs/mobx-react/issues/545)
43
44### 5.2.6
45
46* Fixed bug in defining properties (although the bug had no known observable effect). Fixes [#540](https://github.com/mobxjs/mobx-react/issues/540)
47
48### 5.2.4 / 5.2.5
49
50* Improved compatibility with React-Hot-Loader, see [#522](https://github.com/mobxjs/mobx-react/pull/522) by [theKashey](https://github.com/theKashey). Fixes [#500](https://github.com/mobxjs/mobx-react/issues/500)
51
52### 5.2.3
53
54* Fixed problem with `Symbol` feature detection. By [@Strate](https://github.com/Strate) through [#501](https://github.com/mobxjs/mobx-react/pull/501). Fixes [#498](https://github.com/mobxjs/mobx-react/issues/498) and [#503](https://github.com/mobxjs/mobx-react/issues/503).
55
56### 5.2.2
57
58* Polyfill `Symbol` if it doesn't exist. By [@Strate](https://github.com/Strate) through [#499](https://github.com/mobxjs/mobx-react/pull/499).
59
60### 5.2.1
61
62* Component `props` and `state` properties are now made observable during the instance creation. This restores the behavior from before 5.1.0 where `props` and `state` could safely be observed during mount. Actually it is now possible to do similar things in constructors as well. Fixes [#478](https://github.com/mobxjs/mobx-react/issues/478). Thanks [@Strate](https://github.com/Strate) for the idea and PR! [#496](https://github.com/mobxjs/mobx-react/pull/496).
63
64### 5.2.0
65
66* Added backward compatible support for MobX 5.
67* Fixed components sometimes being displayed as `undefined` in mobx-devtools. See [#470](https://github.com/mobxjs/mobx-react/pull/470) by [@MauricioAndrades](https://github.com/MauricioAndrades)
68* Removed unnecessary warning `@observer` was used both on a sub and super class. See [#492](https://github.com/mobxjs/mobx-react/pull/476) by [@skiritsis](https://github.com/skiritsis). _N.B. putting `@observer` on a super and subclass is still not an supported pattern, use @observer on subclasses only!_
69
70### 5.1.2
71
72* Fixed regression bug in integration with devtools. Fixed through [#465](https://github.com/mobxjs/mobx-react/pull/465) by @le0nik
73
74### 5.1.0
75
76* Added support for React 16.3, including support for the `getDerivedStateFromProps` life-cycle hook. MobX will no longer use `componentWillMount` hook internally, so that it can be used in `StrictMode` react as well. Fixes [#447](https://github.com/mobx/mobx-react/447)
77* Static properties of a function component are now automatically hoisted when the component is wrapped by `observer`. Implements [#427](https://github.com/mobx/mobx-react/427)
78* Misspelled export `componentByNodeRegistery` is now properly export as `componentByNodeRegistry` as well, please update consumers, the mispelled version will be dropped in the next major. Fixes [#421](https://github.com/mobx/mobx-react/421)
79* Deprecated the support for the `inject` property on `Observer`, it is fundamentally broken and should not be used. Use `inject` on the enclosing component instead and grab the necessary stores from the closure. Fixes [#423](https://github.com/mobx/mobx-react/423)
80* Added warning about using `observer` on a React.PureComponent, this will become an exception in the next major. Fixes [#309](https://github.com/mobx/mobx-react/309)
81* Mobx-react will now print a warning when combining `observer` with a custom `shouldComponentUpdate` implementation. Fixes [#417](https://github.com/mobx/mobx-react/417)
82
83### 5.0.0
84
85* Added compatibility with MobX 4.x. This version is not compatible with older Mobx versions
86
87### 4.4.3
88
89* The exposed React Native build now uses commonjs, to prevent the need of further transpilation. Fixes [#428](https://github.com/mobxjs/mobx-react/issues/428)
90
91### 4.4.2
92
93* Fixed issue with mobx-react not compiling on react-native due to the presence of a `.babelrc` file. Fixes [#415](https://github.com/mobxjs/mobx-react/issues/415) by [Ryan Rampersad](https://github.com/ryanmr) through [#416](https://github.com/mobxjs/mobx-react/pull/416)
94
95### 4.4.1
96
97* Fixed syntax error in 4.4.0 that escaped
98
99### 4.4.0
100
101* `Observer` now supports render props, `render` and `inject`. See the updated readme. By [ZiYingMai](https://github.com/Sunshine168) through [#403](https://github.com/mobxjs/mobx-react/pull/403)
102* Fixed: `NaN` is now considered to be equal to `NaN` when doing reconciliation. Fixes [#363](https://github.com/mobxjs/mobx-react/issues/363), by [Andrew Branch](https://github.com/andrewbranch) through [#402](https://github.com/mobxjs/mobx-react/pull/402)
103* Improved typings of `Observer` component, by [Rafał Filipek](https://github.com/RafalFilipek) through [#376](https://github.com/mobxjs/mobx-react/pull/376)
104* Fixed incorrect generation of component name, by [Andy Kogut](https://github.com/andykog) through [#368](https://github.com/mobxjs/mobx-react/pull/368)
105* Lot of internal repo upgrades: Test suite is now in Jest, Prettier is used etc.
106
107### 4.3.5
108
109Fixed some issues with the typescript typings. See for example #353
110
111### 4.3.4
112
113Improved typescript typings, including support for `strict` mode in TS 2.6. Fixes
114
115### 4.3.3
116
117Added support for React 16. (No changes)
118
119### 4.3.2
120
121Killed accidentally exposed default exports.
122
123If you are still using `import mobxReact from "mobx-react"`, use `import * as mobxReact from "mobx-react"`, or better `import { whatYouNeed } from "mobx-react"` instead.
124
125### 4.3.1
126
127### 4.3.0 (unpublished)
128
129Improved module rollup setup, enabling better tree shaking. See #324 / #328
130
131### 4.2.2
132
133* Fixed check for stateless components, by @leader22, see #280
134
135### 4.2.1
136
137_Note: Due to pull / rebase issue the release commit is incorrect. This is the released [commit](https://github.com/mobxjs/mobx-react/commit/f1b3eefc5239cb451b317204fa8aad94b4dcfc2f)_
138
139* Reduced module size by 31% (switched to rollup.js). See #244 by @rossipedia
140* Skip creation of `.wrappedInstance` reference for stateless components. See #254 by @farwayer
141* Introduced global `onError` handler hook to be notified on errors thrown by `@observer` components. See #262 by @andykog
142* Improved typescript typings of the exposed `propTypes`, See #263 by @panjiesw
143
144### 4.2.0
145
146* Same as 4.2.1, but contained build issue and is unpublished
147
148### 4.1.8
149
150* Undid change introduced in 4.1.4 where the lifecycle hooks were protected, as this breaks react-hot-loader.... Fixes #231
151
152### 4.1.7
153
154* Added support for React 15.5 (no deprecation warnings) and 16.0 (no proptypes / createClass), by @andykog, see #238. Fixes #233, #237
155
156### 4.1.5
157
158* Improved typescript typings, fixes #223
159
160### 4.1.4
161
162* Made lifecycle hooks used by mobx-react read-only to make sure they are not accidentally overwritten in component instances. Fixes, #195, #202. Note that they can still be defined, just make sure to define them on the prototype (`componentWillMount() {}`) instead of the instance (`componentWillMount = () => {}`). Which is best practice anyway.
163
164### 4.1.3
165
166* Fixed `ReactDOM.findDOMNode` exception when using react-test-runner, #216
167
168### 4.1.2
169
170* Exceptions caught during render are now rethrown with proper stack, fixes #206
171
172### 4.1.1
173
174* Exposed `wrappedInstance` and `wrappedComponent` in typings
175* Fixed accidental use of `default` import from `mobx` package.
176
177### 4.1.0
178
179* Added support for MobX3. Note that using MobX3 changes the error semantics. If an `observer` component throws, it will no longer crash the app, but just log the exceptions instead.
180
181### 4.0.4
182
183* Introduced `suppressChangedStoreWarning` to optionally supresss change store warnings, by @dropfen, see #182, #183
184
185### 4.0.3
186
187* Fixed issue where userland componentWilMount was run before observer componentWillMount
188
189### 4.0.2
190
191* Fixed order of `inject` overloads, see #169
192* Fixed import of `mobx` when using Webpack without commonjs plugin, see: #168
193
194### 4.0.1
195
196* Improved typings, by @timmolendijk, fixes #164, #166
197* Fixed `inject` signature in readme, by @farwayer
198
199### 4.0.0
200
201#### `observer` now uses shallow comparision for all props _(Breaking change)_
202
203`observer` used to compare all properties shallow in the built-in _shouldComponentUpdate_, except when it received
204non-observable data structures.
205Because mobx-react cannot know whether a non observable has been deeply modified, it took no chances and just re-renders.
206
207However, the downside of this when an unchanged, non-observable object is passed in to an observer component again, it would still cause a re-render.
208Objects such as styling etc. To fix this mobx-react will now always compare all properties in a pure manner.
209In general this should cause no trouble, as typically mutable data in mobx based objects is captured in observable objects, which will still cause components to re-render if needed.
210
211If you need to pass in a deeply modified object and still want to make sure to cause a re-render, either
212
213* make sure the object / array is an observable
214* do not decorate your component with `observer`, but use `Observer` regions instead (see below)
215
216See [#160](https://github.com/mobxjs/mobx-react/issues/160) for more details.
217
218#### `inject(fn)(component)` will now track `fn` as well
219
220`inject(func)` is now reactive as well, that means that transformations in the selector function will be tracked, see [#111](https://github.com/mobxjs/mobx-react/issues/111)
221
222```javascript
223const NameDisplayer = ({ name }) => <h1>{name}</h1>
224
225const UserNameDisplayer = inject(stores => ({
226 name: stores.userStore.name
227}))(NameDisplayer)
228
229const user = mobx.observable({
230 name: "Noa"
231})
232
233const App = () => (
234 <Provider userStore={user}>
235 <UserNameDisplayer />
236 </Provider>
237)
238
239ReactDOM.render(<App />, document.body)
240```
241
242_N.B. note that in this specific case NameDisplayer doesn't have to be an `observer`, as it doesn't receive observables, but just plain data from the transformer function._
243
244#### `this.props` and `this.state` in React components are now observables as well
245
246A common cause of confusion were cases like:
247
248```javascript
249@observer class MyComponent() {
250 @computed upperCaseName() {
251 return this.props.user.name.toUpperCase()
252 }
253
254 render() {
255 return <h1>{this.upperCaseName}</h1>
256 }
257}
258```
259
260This component would re-render if `user.name` was modified, but it would still render the previous user's name if a complete new user was received!
261The reason for that is that in the above example the only observable tracked by the computed value is `user.name`, but not `this.props.user`.
262So a change to the first would be picked up, but a change in `props` itself, assigning a new user, not.
263
264Although this is technically correct, it was a source of confusion.
265For that reason `this.state` and `this.props` are now automatically converted to observables in any `observer` based react component.
266For more details, see [#136](https://github.com/mobxjs/mobx-react/pull/136) by @Strate
267
268#### Better support for Server Side Rendering
269
270Introduced `useStaticRendering(boolean)` to better support server-side rendering scenarios. See [#140](https://github.com/mobxjs/mobx-react/issues/140)
271
272#### Introduced `Observer` as alternative syntax to the `observer` decorator.
273
274_This feature is still experimental and might change in the next minor release, or be deprecated_
275
276Introduced `Observer`. Can be used as alternative to the `observer` decorator. Marks a component region as reactive.
277See the Readme / [#138](https://github.com/mobxjs/mobx-react/issues/138)
278Example:
279
280```javascript
281const UserNameDisplayer = ({ user }) => <Observer>{() => <div>{user.name}</div>}</Observer>
282```
283
284#### Using `observer` to inject stores is deprecated
285
286The fact that `observer` could inject stores as well caused quite some confusion.
287Because in some cases `observer` would return the original component (when not inject), but it would return a HoC when injecting.
288To make this more consistent, you should always use `inject` to inject stores into a component. So use:
289
290```
291@inject("store1", "store2") @observer
292class MyComponent extends React.Component {
293```
294
295or:
296
297```
298const MyComponent = inject("store1", "store2")(observer(props => rendering))
299```
300
301For more info see the related [discussion](https://github.com/mobxjs/mobx-react/commit/666577b41b7af8209839e7b243064a31c9951632#commitcomment-19773706)
302
303#### Other improvements
304
305* If `mobx` and `mobx-react` are used in combination, all reactions are run as part of React's batched updates. This minimizes the work of the reconciler, guarantees optimal rendering order of components (if the rendering was not triggered from within a React event). Tnx @gkaemmer for the suggestion.
306* It is now possible to directly define `propTypes` and `defaultProps` on components wrapped with `inject` (or `observer(["stores"])`) again, see #120, #142. Removed the warnings for this, and instead improved the docs.
307* Clean up data subscriptions if an error is thrown by an `observer` component, see [#134](https://github.com/mobxjs/mobx-react/pull/134) by @andykog
308* export `PropTypes` as well in typescript typings, fixes #153
309* Add react as a peer dependency
310* Added minified browser build: `index.min.js`, fixes #147
311* Generate better component names when using `inject`
312
313---
314
315### 3.5.9
316
317* Print warning when `inject` and `observer` are used in the wrong order, see #146, by @delaetthomas
318
319### 3.5.8
320
321* Fixed issue where `props` where not passed properly to components in very rare cases. Also fixed #115
322
323### 3.5.7
324
325* Bundles are no longer minified, fixes #127
326
327### 3.5.6
328
329* Export `propTypes` as `PropTypes`, like React (@andykog, ##117)
330
331### 3.5.5
332
333* Removed `experimental` status of `inject` / `Provider`. Official feature now.
334* Fixed hot-reloading issue, #101
335
336### 3.5.4
337
338* Introduced `wrappedInstance` by @rossipedia on `inject` decorated HOC's, see https://github.com/mobxjs/mobx-react/pull/90/
339* print warnings when assign values to `propTypes`, `defaultProps`, or `contextTypes` of a HOC. (by @jtraub, see https://github.com/mobxjs/mobx-react/pull/88/)
340* Static properties are now hoisted to HoC components when, #92
341* If `inject` is used incombination with a function, the object return from the function will now be merged into the `nextProps` instead of replacing them, #80
342* Always do propType checking untracked, partially fixes #56, #305
343
344### 3.5.3
345
346* Fixed error `Cannot read property 'renderReporter' of undefined` (#96)
347
348### 3.5.2
349
350* Added propTypes.observableArrayOf and propTypes.arrayOrObservableArrayOf (#91)
351
352### 3.5.1
353
354* Fixed regression #85, changes caused by the constructor results in inconsistent rendering (N.B.: that is un-idiomatic React usage and React will warn about this!)
355
356### 3.5.0
357
358* Introduced `inject("store1", "store2")(component)` as alternative syntax to inject stores. Should address #77, #70
359* Introduced the `wrappedComponent` property on injected higher order components, addresses #70, #72
360* Fixed #76: error when no stores are provided through context
361* Added typings for devTools related features (@benjamingr).
362* Added MobX specific propTypes (@mattruby)
363* Merged #44, fixes #73: don't re-render if component was somehow unmounted
364
365### 3.4.0
366
367* Introduced `Provider` / context support (#53 / MobX #300)
368* Fixed issues when using devtools with IE. #66 (By @pvasek)
369
370### 3.3.1
371
372* Added typescript typings form `mobx-react/native` and `mobx-react/custom`
373* Fixed #63: error when using stateless function components when using babel and typescript
374
375### 3.3.0
376
377* Upgraded to MobX 2.2.0
378
379### 3.2.0
380
381* Added support for react-native 0.25 and higher. By @danieldunderfelt.
382
383### 3.1.0
384
385* Added support for custom renderers (without DOM), use: `mobx-react/custom` as import fixes #42
386* Fixed some issues with rollup #43
387* Minor optimization
388
389### 3.0.5
390
391Introduced `componentWillReact`
392
393### 3.0.4
394
395The debug name stateless function components of babel transpiled jsx are now properly picked up if the wrapper is applied after defining the component:
396
397```javascript
398const MyComponent = () => <span>hi</span>
399
400export default observer(MyComponent)
401```
402
403### 3.0.3
404
405Removed peer dependencies, React 15 (and 0.13) are supported as well. By @bkniffler
406
407### 3.0.2
408
409Removed the warning introduced in 3.0.1. It triggered always when using shallow rendering (when using shallow rendering `componentDidMount` won't fire. See https://github.com/facebook/react/issues/4919).
410
411### 3.0.1
412
413Added warning when changing state in `getInitialState` / `constructor`.
414
415### 3.0.0
416
417Upgraded to MobX 2.0.0
418
419### 2.1.5
420
421Improved typescript typings overloads of `observer`
422
423### 2.1.4
424
425Added empty 'dependencies' section to package.json, fixes #26
426
427### 2.1.3
428
429Added support for context to stateless components. (by Kosta-Github).
430
431### 2.1.1
432
433Fixed #12: fixed React warning when a component was unmounted after scheduling a re-render but before executing it.
434
435### 2.1.0
436
437Upped dependency of mobx to 1.1.1.
438
439### 2.0.1
440
441It is now possible to define `propTypes` and `getDefaultProps` on a stateless component:
442
443```javascript
444const myComponent = props => {
445 // render
446}
447
448myComponent.propTypes = {
449 name: React.PropTypes.string
450}
451
452myComponent.defaultProps = {
453 name: "World"
454}
455
456export default observer(myComponent)
457```
458
459All credits to Jiri Spac for this contribution!
460
461### 2.0.0
462
463Use React 0.14 instead of React 0.13. For React 0.13, use version `mobx-react@1.0.2` or higher.
464
465### 1.0.2
466
467Minor fixes and improvements
468
469### 1.0.1
470
471Fixed issue with typescript typings. An example project with MobX, React, Typescript, TSX can be found here: https://github.com/mobxjs/mobx-react-typescript
472
473### 1.0.0
474
475`reactiveComponent` has been renamed to `observer`
476
477### 0.2.3
478
479Added separte import for react-native: use `var reactiveComponent = require('mobx-react/native').reactiveComponent` for native support; webpack clients will refuse to build otherwise.
480
481### 0.2.2
482
483Added react-native as dependency, so that the package works with either `react` or `react-native`.
484
485### 0.2.0
486
487Upgraded to MobX 0.7.0
488
489### 0.1.7
490
491Fixed issue where Babel generated component classes where not properly picked up.
492
493### 0.1.6
494
495`observer` now accepts a pure render function as argument, besides constructor function. For example:
496
497```javascript
498var TodoItem = observer(function TodoItem(props) {
499 var todo = props.todo
500 return <li>{todo.task}</li>
501})
502```
503
504### 0.1.5
505
506observer is now defined in terms of side effects.
507
508### 0.1.4
509
510Added support for React 0.14(RC) by dropping peer dependency