Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0606de0

Browse files
committed
0.11-rc blog post
(cherry picked from commit b8cc3f5)
1 parent 1381775 commit 0606de0

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
---
2+
title: React v0.11 RC
3+
layout: post
4+
author: Paul O’Shannessy
5+
---
6+
7+
It's that time again… we're just about ready to ship a new React release! v0.11 includes a wide array of bug fixes and features. We highlighted some of the most important changes below, along with the full changelog.
8+
9+
The release candidate is available for download from the CDN:
10+
11+
* **React**
12+
Dev build with warnings: <http://fb.me/react-0.11.0-rc1.js>
13+
Minified build for production: <http://fb.me/react-0.11.0-rc1.min.js>
14+
* **React with Add-Ons**
15+
Dev build with warnings: <http://fb.me/react-with-addons-0.11.0-rc1.js>
16+
Minified build for production: <http://fb.me/react-with-addons-0.11.0-rc1.min.js>
17+
* **In-Browser JSX transformer**
18+
<http://fb.me/JSXTransformer-0.11.0-rc1.js>
19+
20+
We've also published version `0.11.0-rc1` of the `react` and `react-tools` packages on npm and the `react` package on bower.
21+
22+
Please try these builds out and [file an issue on GitHub](https://github.com/facebook/react/issues/new) if you see anything awry.
23+
24+
25+
# Blog Post
26+
27+
## `getDefaultProps`
28+
29+
Starting in React 0.11, `getDefaultProps()` is called only once when `React.createClass()` is called, instead of each time a component is rendered. This means that `getDefaultProps()` can no longer vary its return value based on `this.props` and any objects will be shared across all instances. This change improves performance and will make it possible in the future to do PropTypes checks earlier in the rendering process, allowing us to give better error messages.
30+
31+
32+
## Rendering to `null`
33+
34+
Since React's release, people have been using work arounds to "render nothing". Usually this means returning an empty `<div/>` or `<span/>`. Some people even got clever and started returning `<noscript/>` to avoid extraneous DOM nodes. We finally provided a "blessed" solution that allows developers to writing meaningful code. Returning `null` in an explicit indication to React that you do not want anything rendered. Behind the scenes we make this work with a `<noscript>` element, though in the future we hope to not put anything in the document. In the mean time, `<noscript>` elements do not affect layout in any way, so you can feel safe using `null` today!
35+
36+
```js
37+
// Before
38+
render: function() {
39+
if (!this.state.visible) {
40+
return <span/>;
41+
}
42+
// ...
43+
}
44+
45+
// After
46+
render: function() {
47+
if (!this.state.visible) {
48+
return null;
49+
}
50+
// ...
51+
}
52+
```
53+
54+
55+
## JSX Namespacing
56+
57+
Another feature request we've been hearing for a long time is the ability to have namespaces in JSX. Given that JSX is just JavaScript, we didn't want to use XML namespacing. Instead we opted for a standard JS approach: object property access. Instead of assigning variables to access components stored in an object (such as a component library), you can now use the component directly as `<Namespace.Component/>`.
58+
59+
```js
60+
// Before
61+
var UI = require('UI');
62+
var UILayout = UI.Layout;
63+
var UIButton = UI.Button;
64+
var UILabel = UI.Label;
65+
66+
render: function() {
67+
return <UILayout><UIButton /><UILabel>text</UILabel></UILayout>;
68+
}
69+
70+
// After
71+
var UI = require('UI');
72+
73+
render: function() {
74+
return <UI.Layout><UI.Button /><UI.Label>text</UI.Label></UI.Layout>;
75+
}
76+
```
77+
78+
79+
## Improved keyboard event normalization
80+
81+
Keyboard events now contain a normalized `e.key` value according to the [DOM Level 3 Events spec](http://www.w3.org/TR/DOM-Level-3-Events/#keys-special), allowing you to write simpler key handling code that works in all browsers, such as:
82+
83+
```js
84+
handleKeyDown: function(e) {
85+
if (e.key === 'Enter') {
86+
// Handle enter key
87+
} else if (e.key === ' ') {
88+
// Handle spacebar
89+
} else if (e.key === 'ArrowLeft') {
90+
// Handle left arrow
91+
}
92+
},
93+
```
94+
95+
Keyboard and mouse events also now include a normalized `e.getModifierState()` that works consistently across browsers.
96+
97+
## Changelog
98+
99+
### React Core
100+
101+
#### Breaking Changes
102+
* `getDefaultProps()` is now called once per class and shared across all instances
103+
104+
#### New Features
105+
* Rendering to `null`
106+
* Keyboard events include normalized `e.key` and `e.getModifierState()` properties
107+
* New normalized `onBeforeInput` event
108+
* `React.Children.count` has been added as a helper for counting the number of children
109+
110+
#### Bug Fixes
111+
112+
* Re-renders are batched in more cases
113+
* Events: `e.view` properly normalized
114+
* Added Support for more HTML attributes (`coords`, `crossOrigin`, `download`, `hrefLang`, `mediaGroup`, `muted`, `scrolling`, `shape`, `srcSet`, `start`, `useMap`)
115+
* Improved SVG support
116+
* Changing `className` on a mounted SVG component now works correctly
117+
* Added support for elements `mask` and `tspan`
118+
* Added support for attributes `dx`, `dy`, `fillOpacity`, `fontFamily`, `fontSize`, `markerEnd`, `markerMid`, `markerStart`, `opacity`, `patternContentUnits`, `patternUnits`, `preserveAspectRatio`, `strokeDasharray`, `strokeOpacity`
119+
* CSS property names with vendor prefixes (`Webkit`, `ms`, `Moz`, `O`) are now handled properly
120+
* Duplicate keys no longer cause a hard error; now a warning is logged (and only one of the children with the same key is shown)
121+
* `img` event listeners are now unbound properly, preventing the error "Two valid but unequal nodes with the same `data-reactid`"
122+
* Added explicit warning when missing polyfills
123+
124+
### React With Addons
125+
* PureRenderMixin:
126+
* Perf: a new set off tools to help with performance analysis
127+
* Update: New `$apply` command to transform values
128+
* TransitionGroup bug fixes with null elements, Android
129+
130+
### React NPM Module
131+
* Now includes the pre-built packages under `dist/`.
132+
* `envify` is properly listed as a dependency instead of a peer dependency
133+
134+
### JSX
135+
* Added support for namespaces, eg `<Components.Checkbox />`
136+
* JSXTransformer
137+
* Enable the same `harmony` features available in the command line with `<script type="text/jsx;harmony=true">`
138+
* Scripts are downloaded in parallel for more speed. They are still executed in order (as you would expect with normal script tags)
139+
* Fixed a bug preventing sourcemaps from working in Firefox
140+
141+
### React Tools Module
142+
* Improved readme with usage and API information
143+
* Improved ES6 transforms available with `--harmony` option
144+
* Added `--source-map-inline` option to the `jsx` executable
145+
* New `transformWithDetails` API which gives access to the raw sourcemap data
146+
147+

docs/downloads/react-0.11.0-rc1.zip

700 KB
Binary file not shown.

0 commit comments

Comments
 (0)