Compare commits

..

1435 Commits

Author SHA1 Message Date
Paul O’Shannessy
7f24943e5a update version for 0.10rc 2014-03-18 22:09:32 -07:00
Paul O’Shannessy
0491d30e7c re-enable moved root warning 2014-03-18 22:03:25 -07:00
Paul O’Shannessy
55b0222596 Upgrade browserify 2014-03-18 21:33:39 -07:00
Paul O’Shannessy
b95fbbe4a2 Silence tests unsupported in PhantomJS.
These tests can still be run in the browser using `grunt test --debug`.

This is a repeat of 42f8d155f8. For posterity, we
do this because Phantom has a problem with Object.freeze and the test runner
can't do __DEV__ right (because we get rid of that in the build step).
2014-03-18 17:48:16 -07:00
Kunal Mehta
e505e47e01 Separate immutable project
This moves Immutable and Immutable object into the new `immutable` project.
2014-03-18 15:03:26 -07:00
Sebastian Markbage
e0c487649d Logging use of objects as maps for children
Let's start logging objects as maps for children. We may want to deprecate this
and replace it with ImmutableMap and Map data structures instead.

This should ideally be logged in the recursive function but since that loses the
scope of where these children are passed it's easier to start tracking them
here to get an idea of how frequently and where it's used.
2014-03-18 15:01:51 -07:00
Andrew Zich
22057ef61c don't try to use Object.prototype methods as transfer strategies in ReactPropTransferer.mergeProps
While looking up a detail of how `transferPropsTo()` works I noticed that we never check `TransferStrategies.hasOwnProperty(thisKey)` when merging props, just `newProps.hasOwnProperty(thisKey)` and a truthy test for `TransferStrategies[thisKey]`. This means that if our `newProps` has keys like `toString`, `valueOf`, or `constructor` etc. set, we will pull these functions off `TransferStrategies` and invoke them when merging props. In most cases this will just result in a failure to merge and some code without side effects being run but in the case of `valueOf` it will actually generate an exception.
2014-03-18 15:01:46 -07:00
Josh Duck
0278f01d95 Replace function expression with for loop
isCustomAttribute used an anonymous function in place of a for loop.
Swap it out so we're not allocating unnecessarily.
2014-03-18 14:57:08 -07:00
Kunal Mehta
0cec4af8d7 Sync latest Immutable changes 2014-03-18 14:57:04 -07:00
Paul O’Shannessy
8d495f3b6e Revert "Merge pull request #1234 from RReverser/pure-cjs"
This reverts commit 7987e6a51d, reversing
changes made to d88d479685.
2014-03-18 11:25:21 -07:00
Ben Newman
7987e6a51d Merge pull request #1234 from RReverser/pure-cjs
Switched from browserify to pure-cjs bundler.
2014-03-18 12:04:58 -04:00
Paul O’Shannessy
d88d479685 Merge pull request #1193 from spicyj/jsx-polygon
Add polygon tag to transform
2014-03-17 10:07:23 -07:00
Ingvar Stepanyan
3f3187c14f Renamed commojs task to bundle, added failing build if bundler failed. 2014-03-17 16:53:02 +02:00
Ben Alpert
c1443e92e6 Merge pull request #1226 from LilyJ/master
included link to React devtools in tooling-integration. fixes #791
2014-03-16 22:42:14 -07:00
Paul O’Shannessy
52e8f3fdb0 Merge pull request #1248 from asolove/svg-text-anchor
Add svg text-anchor attribute
2014-03-16 22:33:00 -07:00
Paul O’Shannessy
cdf4f07a15 Merge pull request #1229 from spicyj/no-jsx
Avoid JSX in ReactCSSTransitionGroup code
2014-03-16 22:31:24 -07:00
Paul O’Shannessy
6ff116e34b Merge pull request #1262 from vjeux/harmony-react-to
Add support for {harmony: true} to react-tools
2014-03-16 22:30:30 -07:00
Pete Hunt
d889a01caf Fix ref behavior for remounting
I'm thinking that setting up `this.refs` in `mountComponent` is better than `construct`. Followed the same pattern as `ReactComponent.Mixin` and nulling out
the value in `construct` and setting it to its initial value in `mountComponent`.
2014-03-16 22:01:54 -07:00
Pete Hunt
04f9887f0e More actionable error message for <tbody> and nested <p>
This bites people all of the time. Until we have a better solution, let's just make the error message more actionable (most people don't know how the DOM
gets unexpectedly mutated).
2014-03-16 22:01:34 -07:00
Sebastian Markbage
9b427a322f Fix some invalid uses of instances
Breaking this out of the other code mod.
2014-03-16 22:01:30 -07:00
Sebastian Markbage
7bbdcdba96 Reassign variable of rendered component
The component that gets passed into renderComponent isn't guaranteed to be the
instance that gets mounted. We want to clone the instance.

Unit tests need to reason about the mounted instance. The first code mod changes:

  ReactTestUtils.renderIntoDocument(<identifier>)

into

  <identifier> = ReactTestUtils.renderIntoDocument(<identifier>)

Using this scripts:

  scripts/bin/codemod -m -d ~/www --extensions js \
   '^(\s*)ReactTestUtils\.renderIntoDocument\(\s*([$a-zA-Z0-9_]+)\s*\)' \
   '\1\2 = ReactTestUtils.renderIntoDocument(\2)'

In the second case I do the same for React.renderComponent. However, there are
alot more unnecessary matches so I only codemod if the same identifier occurs
later in the file.

  scripts/bin/codemod -m -d ~/www --extensions js \
   '^(\s*)React.renderComponent\(\s*([$a-zA-Z0-9_]+)\s*?,(.*?\n?.*?\s\2\b)' \
   '\1\2 = React.renderComponent(\2,\3'

And one more for ReactMount.renderComponent used by internals.

  scripts/bin/codemod -m -d ~/www --extensions js \
   '^(\s*)ReactMount.renderComponent\(\s*([$a-zA-Z0-9_]+)\s*?,(.*?\n?.*?\s\2\b)' \
   '\1\2 = ReactMount.renderComponent(\2,\3'

This still matches many unnecessary cases where the second occurance of the
identifier is a redeclaration or comment. But this code mod doesn't hurt in
those cases.

Finally I have to do the same for:

  this.<identifier> = React.renderComponent(this.<identifier>,

This is a common pattern for production code but not tests. Some of these call
sites will likely break when we move to true descriptors.

  scripts/bin/codemod -m -d ~/www --extensions js \
   '^(\s*)React.renderComponent\((\s*)this\.([$a-zA-Z0-9\_\.]+)\s*?,' \
   '\1this.\3 = React.renderComponent(\2this.\3,'
2014-03-16 22:01:09 -07:00
Christopher Chedeau
5106b793f7 Add support for {harmony: true} to react-tools
```
require('react-tools').transform(code, {harmony: true});
```

now enables all the harmony es6 transforms that are supported.

This is modeled after https://github.com/facebook/react/blob/master/bin/jsx#L17-L23
2014-03-16 15:38:40 -07:00
Jonas Gebhardt
83e4ef16e6 Community Round-up #18 2014-03-14 16:56:12 -07:00
Paul O’Shannessy
308c9a0752 Merge pull request #1181 from lrowe/patch-5
omitClose for all void elements
2014-03-12 16:37:52 -07:00
Adam Solove
6a01752f3d Add svg text-anchor attribute. 2014-03-12 10:07:05 -04:00
Ben Alpert
6fd53815cd Merge pull request #1246 from ericflo/patch-1
Remove Shirtstarter as an example application.
2014-03-11 15:48:20 -07:00
Eric Florenzano
3efa02da91 Remove Shirtstarter as an example application.
We have unexpectedly had to shut Shirtstarter down, so it won't serve as a good React.js example any more unfortunately -- sorry for the documentation churn.
2014-03-11 15:45:14 -07:00
Jeff Morrison
d9af091244 Merge pull request #1242 from syranide/jsxcomfix
Unbreak JSX comment comma fix
2014-03-11 10:13:24 -07:00
Ingvar Stepanyan
25773ed1b3 CommonJS builder config to Grunt style for easier handling and readability. 2014-03-11 13:40:38 +00:00
Ingvar Stepanyan
9e224e615f Renamed browserify tasks/configs to cjs, updated pure-cjs to 1.9.0 for better build speed. 2014-03-11 13:26:36 +02:00
Cheng Lou
3ce2cd04e2 Merge pull request #1243 from jeffcarp/master
Remove unused variable in ballmer-peak
2014-03-10 21:29:35 -07:00
Jeff Carpenter
652f5aea28 Remove unused variable 2014-03-10 19:48:13 -07:00
Andreas Svensson
280ff2e5a7 Unbreak JSX comment comma fix 2014-03-11 00:31:59 +01:00
Pete Hunt
5ede7fb619 ReactDOMComponent optimization
Slight optimization to not do unneeded reconciles of DOM components
2014-03-10 15:32:20 -07:00
Sebastian Markbage
3ea3274ca4 Clone on mount
This is the first step towards descriptors. This will start cloning the
component when it's mounted instead of mounting the first instance.

This avoids an issue where a reference to the first instance can hang around
in props. Since a mounted component gets mutated, the descriptor changes.

We don't need to clone the props object itself. Mutating the shallow props
object of a child that's passed into you is already flawed. Those cases need to
use cloneWithProps. A props object is considered shallow frozen after it leaves
the render it was created in.
2014-03-10 15:28:54 -07:00
Paul O’Shannessy
2ca810fbf3 Merge pull request #1225 from spicyj/cprop
Fix removing DOM property with mapped name
2014-03-10 11:29:10 -07:00
Pete Hunt
d9dd9d5cb3 Merge pull request #1235 from fxbois/master
Update 08-tooling-integration.md
2014-03-08 20:15:45 -08:00
fxbois
9ffd70c688 Update 08-tooling-integration.md
emacs compatibility
2014-03-08 18:12:05 +01:00
Ingvar Stepanyan
3171436d97 Switched from browserify to pure-cjs bundler.
Optimizations and fix for JSXTransformer build.
Dropped dependency on emulation of Node.js native modules.
Added deamdify step for JSXTransformer build.
2014-03-08 16:33:58 +02:00
Jeff Morrison
9ce7ecc3d9 Merge pull request #1219 from syranide/jsxempty
Fix empty JSX expressions sometimes emitting erroneous commas
2014-03-07 21:23:55 -08:00
Paul O’Shannessy
9f9c8bcebf Merge pull request #1228 from spicyj/grunt-debug
Bring back `grunt test --debug`
2014-03-07 11:18:29 -08:00
Ben Alpert
ec54dcbd8f Avoid JSX in ReactCSSTransitionGroup code
Supposedly we want these to be plain JS.
2014-03-06 22:16:25 -08:00
Ben Alpert
9766ed5797 Bring back grunt test --debug 2014-03-06 22:11:55 -08:00
Ben Alpert
1d209248ef Remove obsolete __VERSION__ references 2014-03-06 20:33:06 -08:00
Ben Alpert
21e06196cd Fix removing DOM property with mapped name 2014-03-06 17:50:01 -08:00
Lily
4b56947560 included link to React devtools in tooling-integration. fixes #791 2014-03-06 13:00:48 -08:00
Paul O’Shannessy
554b677e60 Merge pull request #1180 from evanc/master
Test that Node is a function before using instanceof on it
2014-03-06 11:02:28 -08:00
Andreas Svensson
aa70419f9d Fix empty JSX expressions sometimes emitting erroneous commas 2014-03-06 13:01:03 +01:00
Cheng Lou
af1b63456e Merge pull request #1222 from spicyj/npm-dl
[docs] Add more words to downloads page
2014-03-05 20:23:10 -08:00
Ben Alpert
ac3051530a [docs] Add more words to downloads page 2014-03-05 20:16:50 -08:00
Paul O’Shannessy
c5f56f318a Merge pull request #1208 from passy/patch-3
Fix docstring typo for pure render mixin
2014-03-05 19:13:22 -08:00
Paul O’Shannessy
be2c185888 Merge pull request #1211 from spicyj/freeze
Add Object.freeze to polyfill list
2014-03-05 12:18:20 -08:00
Paul O’Shannessy
7d0e6c6c0b Merge pull request #1192 from spicyj/srcset
Add srcSet attribute
2014-03-04 21:39:46 -08:00
Jing Chen
13aa8d37e6 Allow falsy values in statics
We found that the component would break if we set any statics with the
value 0. It turns out @chenglou already ran into this with
d71736b3ed but the statics code was copied
earlier, and still has this falsy check. Made the same change, updated
the unittest.
2014-03-04 18:15:49 -08:00
Kunal Mehta
06f762da77 Add Immutable
As titled. First of 3 diffs to add Immutable, ImmutableMap, and ImmutableObject. No logic changes.
2014-03-04 18:14:47 -08:00
Kunal Mehta
4ad320dd13 LegacyImmutableObject module
This copies the old implementation of ImmutableObject into LegacyImmutableObject.
2014-03-04 18:14:12 -08:00
Ben Newman
521201f121 Merge pull request #1215 from benjamn/fix-cloneWithProps-test
Fix stale usage of emptyObject in cloneWithProps-test.
2014-03-04 13:27:59 -05:00
Ben Newman
41d30bb7de Re-require cloneWithProps as well, for consistency.
And don't mock `emptyObject`, since that might actually replace it with a
mutable/non-frozen object.
2014-03-04 13:12:59 -05:00
Ben Newman
9c87aef67f Fix stale usage of emptyObject in cloneWithProps-test.
After we run `require('mock-modules').dumpCache()`, the object exported by
the `emptyObject` module will no longer be identical to previously
exported objects, so tests like `expect(component.refs).toBe(emptyObject)`
will fail.

Note that this behavior only manifests itself in tests, because of course
we do not call `dumpCache` in production code.

We could consider storing the `emptyObject` globally to thwart the effects
of `dumpCache`, but it's more idiomatic simply to re-`require` the latest
version of `emptyObject`.
2014-03-04 12:59:55 -05:00
Ben Alpert
ec8b0d7fbf Add srcSet attribute
Chrome beta supports this now: http://blog.chromium.org/2014/02/chrome-34-responsive-images-and_9316.html.
2014-03-03 17:12:00 -08:00
Ben Alpert
e954a1c0d9 Add Object.freeze to polyfill list 2014-03-03 15:55:19 -08:00
Paul O’Shannessy
1d27770b40 Fix verion-check to look in right place for React.js 2014-03-03 15:35:10 -08:00
Paul O’Shannessy
4c4446d283 Sync more vendored modules 2014-03-03 15:34:14 -08:00
Pete Hunt
a8fc3b940d Move UI-thread-only browser modules to browser/ui/
This also deletes an unused module.
2014-03-03 15:07:11 -08:00
Pete Hunt
6666538316 Unbreak refs
If no refs are rendered, `this.refs` is undefined. This is bad since it deopts & is hard to look for. Instead we should make `this.refs` an immutable empty object.
2014-03-03 15:06:57 -08:00
Sebastian Markbage
620c1bc2ff Add more owner context to monitoring
Always include context and specifically include the component that was missing a key.
2014-03-03 15:06:39 -08:00
Cheng Lou
99dab49f92 Refactor rendering to string without checksum & React ID
Finalize API for rendering to static markup.
Instead of passing a boolean option to `renderComponentToString`, just use another method.
2014-03-03 15:06:27 -08:00
Pete Hunt
9b0534eb77 ReactRAFBatchingStrategy
This will go in React addons only for now until we figure out `pendingState`.
2014-03-03 15:06:14 -08:00
Sebastian Markbage
eee04b19e1 Add monitor module for logging instrumentation
This adds an instrumentation hook for logging so that we can monitor invalid API
usage before we're ready to issue a warning.

I took the opportunity to update some console.warns to use the warning module
instead. The remaining console.warns
will be replaced by the warning module after we've cleaned up the callsites.
2014-03-03 15:05:53 -08:00
Cheng Lou
f734083a17 Better name for server-side rendering without React ID & checksum
"staticMarkup" sounds way better than "noChecksumNoID".
Also avoids some double negations.
2014-03-03 15:05:35 -08:00
Christoph Pojer
3fe9f9f336 Fix ReactPropTypesTest
children should never be defined as propType, so changing the test to use an actual prop.
2014-03-03 15:05:26 -08:00
Jan Kassens
e39c19423a temporarily disable warning 2014-03-03 15:05:10 -08:00
Cheng Lou
6203e53d16 Fix IE8 disabled input throwing on focus
When IE8 focuses a disabled item, it throws
This makes sure the we're not focusing the item during selection restoration/autofocus when the element's disabled.
2014-03-03 15:04:34 -08:00
Ben Alpert
88a4a566ae Merge pull request #1209 from petehunt/thinking-in-react
Add thinking in react to the official docs + cleanup
2014-03-03 10:40:28 -08:00
petehunt
2f6656e3e9 fix 2014-03-03 10:39:41 -08:00
petehunt
a0ecf47242 Add thinking in react to the official docs 2014-03-03 10:37:33 -08:00
Cheng Lou
4b670a08fa Merge pull request #1207 from passy/patch-2
Add missing backtick in complementary-tools.md
2014-03-02 16:21:35 -08:00
Pascal Hartig
6b78cfb0f4 Fix docstring typo for pure render mixin 2014-03-02 22:18:10 +00:00
Pascal Hartig
8df5e55efd Add missing backtick in complementary-tools.md 2014-03-02 22:10:24 +00:00
Pete Hunt
237adacc3a Merge pull request #1204 from jmingov/patch-1
Updated React Version to 0.9.0
2014-03-01 17:01:12 -08:00
Pete Hunt
90e996324a Merge pull request #1203 from fson/jsx-integrations
Merge the lists of JSX integrations in the docs.
2014-03-01 14:24:58 -08:00
3boll
b2649dd73b Updated React Version 0.9.0
**Updated Url's:**

CDN:

    http://fb.me/react-0.9.0.js

    http://fb.me/JSXTransformer-0.9.0.js

Starter Kit

    http://facebook.github.io/react/downloads/react-0.9.0.zip
2014-03-01 21:12:17 +01:00
Ville Immonen
0217461d16 Merge the lists of JSX integrations in the docs.
There were these two lists of JSX tools at Complimentary Tools
and Tooling Integration, that were a bit out of sync with each other.

Bring them together and add a link to the former from the latter.
2014-03-01 16:50:40 +02:00
Pete Hunt
3c4f45fe45 Merge pull request #1200 from ericflo/patch-1
Add Shirtstarter to examples of production apps.
2014-02-28 13:42:28 -08:00
Eric Florenzano
6485e21956 Add Shirtstarter to examples of production apps.
Shirtstarter is 100% built on React.
2014-02-28 13:40:14 -08:00
Paul O’Shannessy
ae72e6ef91 Merge pull request #1082 from spicyj/class-false
Ensure className={false} turns into string 'false'
2014-02-27 16:41:41 -08:00
Ben Alpert
42444f6bb9 Add polygon tag to transform
Fixes #1144.
2014-02-27 12:32:24 -08:00
Ben Alpert
298a05517e Tweak propTypes examples for clarity in oneOfType 2014-02-26 15:03:47 -08:00
Laurence Rowe
cbfbb54c1d omitClose for all void elements
According to http://www.w3.org/TR/html5/syntax.html#void-elements the following elements should not specify end tags:

area, base, br, col, embed, hr, img, input, keygen, link, meta, param, source, track, wbr
2014-02-25 20:03:16 -08:00
evanc
26179d2b79 Test that Node is a function before using instanceof on it 2014-02-25 17:55:31 -08:00
Pete Hunt
ba78edbed8 Update complementary-tools.md 2014-02-25 17:01:00 -08:00
Paul O’Shannessy
34b6707132 Merge pull request #1166 from chenglou/docs-examples-consolidate
[Docs] Consolidate the two examples sections
2014-02-25 16:45:01 -08:00
Paul O’Shannessy
7b773a6b3d make <hasOwnProperty/> transform correctly 2014-02-24 18:03:02 -08:00
Paul O’Shannessy
1dfc5c79f9 Merge pull request #1148 from spicyj/jsx-constructor
Make JSX transform not break on 'constructor' attr
2014-02-24 17:20:25 -08:00
Ben Alpert
04111d5228 Add acknowledgements page 2014-02-24 17:18:57 -08:00
Jonas Gebhardt
a6c1b91c7d fix typo in community round-up #17 2014-02-24 15:27:02 -08:00
Pete Hunt
f34f0d2912 Update README.md 2014-02-24 14:25:09 -08:00
Pete Hunt
46cae63d2c Merge pull request #1156 from chenglou/1154
Remove TodoMVCs from examples/
2014-02-24 14:24:12 -08:00
Jonas Gebhardt
5049fc6b05 Community Round-up # 17 2014-02-24 14:20:17 -08:00
Pete Hunt
8b1279e6b2 Merge pull request #1174 from spicyj/addons-update
Add update() to React.addons
2014-02-24 14:10:07 -08:00
Ben Alpert
854d1f7c1b Add update() to React.addons 2014-02-24 14:05:29 -08:00
Pete Hunt
ab2d59f8b0 [addons] update() immutability helper
Dealing with immutable data is hard. This provides a simple helper (ported from the IG codebase) that makes dealing with immutable JSON data easier. Designed to be familiar for people who use MongoDB.
2014-02-24 13:58:51 -08:00
Cheng Lou
25cafec4a9 [Docs] Consolidate the two examples sections
Also made the formatting more consistent between complementary-tools and
examples.
2014-02-23 18:58:28 -08:00
Ben Alpert
61c287c5ea [docs] Fix version in lifecycle argument note
Fixes #1163.
2014-02-23 16:49:27 -08:00
Pete Hunt
7bba8c3257 Merge pull request #1155 from petehunt/update-helper
Add update() docs
2014-02-21 15:58:39 -08:00
Cheng Lou
2f0507f730 Remove TodoMVCs from examples/
Fixes #1154.
Added a README to point to TodoMVC's site instead.
2014-02-21 14:31:54 -08:00
petehunt
989f6f987d Add update() docs 2014-02-21 13:07:51 -08:00
Ben Alpert
e2b006f9ae .dataTransfer not .dragTransfer 2014-02-21 12:13:21 -08:00
Ben Alpert
141ff66986 Merge pull request #1150 from andreypopp/update-react-router-component-link
docs: update react-router-component link
2014-02-21 11:30:26 -08:00
Andrey Popp
da0b34e945 docs: update link for react-async 2014-02-21 18:30:19 +04:00
Andrey Popp
cbce621570 docs: update react-router-component link 2014-02-21 15:51:27 +04:00
Ben Alpert
472be09ff6 Make JSX transform not break on 'constructor' attr 2014-02-20 21:44:58 -08:00
Ben Alpert
7144a9f241 Merge pull request #1146 from dlau/patch-1
incorrect include in css transition group example?
2014-02-20 19:13:14 -08:00
Daryl Lau
8aaf5fdbf4 incorrect include in css transition group example?
TransitionGroup maps to ReactTransitionGroup, shouldn't it be a ReactCSSTransitionGroup?
2014-02-20 18:26:56 -08:00
Ben Alpert
445611f3e6 Add html5shiv to polyfill docs
cf. #1030
2014-02-20 17:21:41 -08:00
Pete Hunt
b79a3cbd21 Break more browser deps in core
This is part of what Sebastian suggested. We require it into every component that explicitly needs it and inject it as a default mixin for composite components in
the browser environment. This change frees us up to inject everything in ReactComponent.
2014-02-20 16:55:17 -08:00
Jason Bonta
0790040aac update docblock
...for typechecking.
2014-02-20 16:55:01 -08:00
Cheng Lou
2900997b5f Fix transaction test comments
Probably got copy/pasted in.
2014-02-20 16:54:52 -08:00
Cheng Lou
7eb33ef176 simplify mountImageIntoNode's way of putting markup in innerHTML
Instead of removing the node from the document before changing its innerHTML, just do it directly.
The comment seems to be outdated for years. http://jsperf.com/detach-while-setting-innerhtml
2014-02-20 16:54:43 -08:00
Cheng Lou
5545887a48 Allow rendering markup string without checksum and React ID
This fixes https://github.com/facebook/react/pull/994.
Also fixes https://github.com/facebook/react/issues/1079.
Server-rendering without ID/checksum now works. Also won't call didMount.
2014-02-20 16:54:20 -08:00
Paul O’Shannessy
e29584b49b Update authors 2014-02-20 15:20:27 -08:00
Jeff Morrison
c43b3f406c Merge pull request #1143 from jeffmo/npm_test
Add support for `npm test`
2014-02-20 13:15:09 -08:00
jeffmo
a4d6796705 Add support for npm test 2014-02-20 13:10:05 -08:00
Ben Alpert
89d4d352e1 Tweak tutorial wording to be more accurate 2014-02-20 11:40:14 -08:00
Paul O’Shannessy
f3c1383af9 Add context deprecation to changelog, reformat 2014-02-20 10:32:21 -08:00
Shaun Trennery
c32e398a5c Addition of 'this.context' component breaking change
this.context on components is now reserved for internal use by React

closes #1141
2014-02-20 10:32:12 -08:00
Paul O’Shannessy
95edc396df version bump to 0.10.0-alpha 2014-02-19 22:53:29 -08:00
Paul O’Shannessy
26cd595a98 update changelog 2014-02-19 22:17:28 -08:00
Paul O’Shannessy
8840ee32f1 Updated Authors 2014-02-19 22:11:50 -08:00
Paul O’Shannessy
bb729a5784 Merge pull request #1131 from spicyj/rel-notes-0.9-2
React v0.9 blog post
2014-02-19 21:47:29 -08:00
Paul O’Shannessy
b99705f690 Merge branch 'joshduck-patch-1'
Closes #989
2014-02-19 18:10:20 -08:00
Paul O’Shannessy
7e7aa21e24 tweak object property warning. 2014-02-19 18:07:24 -08:00
Ben Alpert
1de77f1fbe Ensure className={false} turns into string 'false'
Fixes inconsistency shown by http://jsfiddle.net/zpao/qeXLm/.
2014-02-19 13:47:35 -08:00
Ben Alpert
01b68c0e76 React v0.9 blog post 2014-02-19 12:05:47 -08:00
Paul O’Shannessy
e59daa8ed8 Add descriptions to package.jsons
Otherwise, npm just reads the first non-header of our readmes, which doesn't
match up accurately or cleanly (no markdown parsing).
2014-02-19 11:35:11 -08:00
Paul O’Shannessy
9b405fba24 Merge pull request #1135 from spicyj/testutils-docs
Update Simulate docs and reorg a little bit
2014-02-19 11:19:27 -08:00
Ben Alpert
99b80938af Update Simulate docs and reorg a little bit 2014-02-19 11:16:55 -08:00
Cheng Lou
e13977c0c2 Merge pull request #939 from spicyj/simulate-synthetic
Simulate synthetic events using ReactTestUtils
2014-02-19 10:58:54 -08:00
Ben Alpert
42473b2df1 Merge pull request #1133 from martinandert/repo-owner-change
complementary-tools repo owner changed
2014-02-19 00:48:15 -08:00
martinandert
970ae44c1f complementary-tools repo owner changed 2014-02-19 09:34:33 +01:00
Ben Alpert
a447d30a2e Rebuild simulators after injecting plugins 2014-02-19 00:28:34 -08:00
Ben Alpert
36e97bac21 Simulate synthetic events using ReactTestUtils
Most of the time this is what you want to do, so I've renamed what was Simulate to be SimulateNative.

Now Simulate.change does what you expect, so this fixes #517 and fixes #519.
2014-02-19 00:04:16 -08:00
Ben Alpert
9f9ee697f3 Simpler ReactTestUtils.simulateEventOnDOMComponent 2014-02-18 23:37:11 -08:00
Pete Hunt
58ffd39abf Merge pull request #1132 from petehunt/docs-clonewithprops
clone docs
2014-02-18 23:27:25 -08:00
petehunt
30faba394d clone docs 2014-02-18 23:26:51 -08:00
Pete Hunt
93e7778d5f Merge pull request #1112 from petehunt/testutils-addons
Add ReactTestUtils to addons
2014-02-18 22:58:30 -08:00
Pete Hunt
b7836c4da6 Merge pull request #1059 from petehunt/rtg-docs
Document ReactCSSTransitionGroup
2014-02-18 22:58:15 -08:00
petehunt
c2904b978e fix docs 2014-02-18 22:57:41 -08:00
petehunt
8122cadeb4 Add ReactTestUtils to addons 2014-02-18 22:54:24 -08:00
petehunt
ea803c47ba docs fixes 2014-02-18 22:51:51 -08:00
petehunt
42c837e4dd remove child factories 2014-02-18 22:48:52 -08:00
petehunt
cadd6cbb6c add ReactCSSTransitionGroup to addons and document it 2014-02-18 22:47:53 -08:00
Paul O’Shannessy
c0660ea6e0 Merge pull request #1100 from plievone/mapchildren-docs
Fix docs for React.Children.map, .forEach, .only.
2014-02-18 21:43:30 -08:00
Paul O’Shannessy
cb1f8247e5 Merge pull request #1130 from spicyj/if-attr-value
Don't break if no attribute value
2014-02-18 18:20:42 -08:00
Ben Alpert
e0dbca1168 Don't break if no attribute value
Fixes the transformation of things like `<button disabled>`.
2014-02-18 18:10:46 -08:00
Paul O’Shannessy
f81d16960c Merge pull request #1128 from spicyj/media-attrs
Add media element attributes
2014-02-18 18:04:43 -08:00
Paul O’Shannessy
8a47813baa Update copyrights for 2014.
grep -rl 'Copyright 2013 Facebook' static_upstream | xargs perl -pi -w -e s/Copyright 2013 Facebook/Copyright 2013-2014 Facebook/g;'

Not going to check in a script to do this since it will just change every year.
Closes #1006
2014-02-18 17:06:43 -08:00
Paul O’Shannessy
792d8aca86 Merge pull request #1116 from spicyj/gh-1115
Add download and hrefLang attributes
2014-02-18 13:42:24 -08:00
Ben Alpert
112a20ce73 Add media element attributes
Fixes #1124.

I didn't add `volume` because it requires more complicated logic to control properly and I didn't add `paused` because to set it we need to call play() or pause() -- perhaps a mutation method is appropriate.
2014-02-18 12:30:14 -08:00
Paul O’Shannessy
c79974db3a Merge pull request #1122 from spicyj/gh-1120
Strip calls to warning() in __DEV__
2014-02-17 19:44:53 -08:00
Ben Alpert
5795376961 Strip calls to warning() in __DEV__
Fixes #1120.
2014-02-17 19:01:45 -08:00
Pete Hunt
8ac5975ad8 Merge pull request #1106 from spicyj/gh-1105
Prevent error thrown when removing event target
2014-02-17 17:53:51 -08:00
Ben Alpert
d8fd1af4a0 Pool ancestors list so event system is reentrant 2014-02-17 16:37:15 -08:00
Ben Newman
f457df275d Merge pull request #1117 from andreypopp/envify-bump
Update envify to 1.2.0
2014-02-17 19:10:13 -05:00
Andrey Popp
39c9b539e9 Update envify to 1.2.0 2014-02-18 03:38:58 +04:00
Ben Alpert
ae7e44ec84 Add download and hrefLang attributes
Fixes #1115.
2014-02-17 15:13:14 -08:00
Pete Hunt
f73b894c37 Update complementary-tools.md 2014-02-17 10:42:09 -08:00
Pete Hunt
4642a70277 Update complementary-tools.md 2014-02-17 10:41:48 -08:00
Ben Alpert
2f0bb69708 Prevent error thrown when removing event target
Fixes #1105.
2014-02-17 10:33:34 -08:00
Pete Hunt
916776753f Merge pull request #1110 from dustingetz/master
Add wingspan-forms to complimentary tools docs
2014-02-17 09:51:43 -08:00
Dustin Getz
1b5af6b405 Add wingspan-forms to complimentary tools docs 2014-02-17 11:48:42 -06:00
Ben Alpert
9e160df868 Blog post for 0.9 release candidate 2014-02-16 18:47:04 -08:00
Paul O’Shannessy
9125f68194 0.9.0-rc1 2014-02-16 17:38:52 -08:00
Ben Alpert
9ebb40f013 Rename dir to npm-jsx_whitespace_transformer 2014-02-16 14:40:03 -08:00
Ben Alpert
7b5da078c6 Make transitions example use CSSTransitionGroup 2014-02-16 14:11:42 -08:00
Ben Alpert
1167aeb453 Expose cloneWithProps on addons
closes #1066
2014-02-16 14:08:05 -08:00
Paul O’Shannessy
6780b47526 Add CSSTransitionGroup to addons
Stealing part of #1059.
2014-02-16 14:04:29 -08:00
Paul O’Shannessy
3e77f64141 Merge pull request #1097 from spicyj/es3ify
Run es3ify over unminified builds
2014-02-16 12:49:16 -08:00
plievone
827c44fcd3 Fix docs for React.Children.map, .forEach, .only. 2014-02-16 22:41:30 +02:00
Pete Hunt
b7ba0f173e Update complementary-tools.md 2014-02-16 12:11:54 -08:00
Ben Newman
634e41788a Merge pull request #1099 from benjamn/make-ReactWebWorker-test-less-flaky
Make ReactWebWorker-test.js less flaky.
2014-02-16 13:58:00 -05:00
Ben Newman
47ae865428 Make ReactWebWorker-test.js less flaky.
Two improvements: make sure we set `done = true` when an error message is
received, so that the test output contains the error message instead of
eventually timing out and displaying nothing useful; and increase the
timeout for this particular test from 5000ms (the default) to 20000ms.
2014-02-16 12:57:14 -05:00
Ben Alpert
0d4213001b Fix typo in latest round-up 2014-02-15 22:53:42 -08:00
Ben Newman
1e7bdc79e1 Upgrade Commoner dependency to v0.9.1 to fix mkdirP bug. 2014-02-15 20:49:17 -05:00
Ben Alpert
e87c8a2aa4 Run es3ify over unminified builds
Makes no difference to react.js and react-with-addons.js; quotes .static in four
places for JSXTransformer.js:

https://gist.github.com/spicyj/aada5352e813752a4667
2014-02-15 16:32:36 -08:00
Paul O’Shannessy
d3c12487fd Update copyright header in browserify config
Part of #1006, but sooner.
2014-02-15 16:24:13 -08:00
Paul O’Shannessy
32e1d76612 Update AUTHORS for 0.9 2014-02-15 16:21:51 -08:00
Jonas Gebhardt
78ac842b4a Add community round-up #16 2014-02-15 15:50:30 -08:00
Paul O’Shannessy
9ebde97c14 Merge pull request #1096 from spicyj/comma-splice
Fix comma splice
2014-02-15 14:07:33 -08:00
Ben Alpert
2013db23d3 Fix comma splice 2014-02-15 13:58:57 -08:00
Paul O’Shannessy
e872cd0a7c Update vendored modules, delete unused
Closes #1090
2014-02-15 13:50:56 -08:00
Paul O’Shannessy
a34eed508a Merge pull request #1095 from jeffmo/sync_transforms
Sync out transforms from fb internal
2014-02-15 12:53:42 -08:00
JeffMo
adcbf0806c Sync out transforms from fb internal 2014-02-15 12:35:32 -08:00
Jeff Morrison
64afa545dd Merge pull request #1094 from jeffmo/jsx_whitespace_codemod_fixup
Pull in syranides jsx whitespace codemod transform fixes
2014-02-15 11:51:54 -08:00
JeffMo
f66f8f0310 Pull in syranides jsx whitespace codemod transform fixes 2014-02-15 11:20:32 -08:00
Jason Bonta
9ba014fbf1 Merge pull request #1081 from spicyj/textcontent
Avoid innerText for better newline behavior
2014-02-15 02:22:54 -06:00
Cheng Lou
d71736b3ed include mixin keys whose values are falsy
the previous behavior is to skip mixin keys whose values are `undefined`, `null`, `''` and (this is a bug) 0. Now, every key is included.
2014-02-14 16:53:34 -08:00
Pete Hunt
529c971db3 Merge pull request #1088 from petehunt/fixtests
Fix CSSTransitionGroup tests
2014-02-14 13:10:38 -08:00
petehunt
b65f5a4d30 fix tests 2014-02-14 12:55:03 -08:00
Cheng Lou
123ed1f442 Fix IE8 bug during unitless CSS props creation
IE8 goes into an infinite loop if we add props to the obj we're iterating through.
2014-02-14 12:41:44 -08:00
Ben Alpert
31bc18d39e Add simple docs on statics to reference section
Fixes #1056.
2014-02-14 11:54:58 -08:00
Cheng Lou
f4798ebee1 [Docs] Add Object.keys to list of shims 2014-02-14 09:52:04 -08:00
Ben Alpert
67c5d76321 Add missing commas in propTypes docs 2014-02-13 23:19:41 -08:00
Pete Hunt
a8af11b46d Merge pull request #1086 from spicyj/new-proptypes
Add docs for new prop types
2014-02-13 23:03:42 -08:00
Ben Alpert
30646c9c1e Add docs for new prop types 2014-02-13 22:59:48 -08:00
Ben Alpert
8c3ac3203d Merge pull request #940 from chenglou/tips-val
[docs] Document newly added unitless css props in tips
2014-02-13 22:40:51 -08:00
Cheng Lou
559933655a [Docs] Document newly added unitless css props in tips 2014-02-13 22:39:30 -08:00
Ben Alpert
0a9eaab61f [docs] Add properties that were in 0.8 too
This time I actually generated it from the DefaultDOMPropertyConfig file.
2014-02-13 22:02:06 -08:00
Paul O’Shannessy
cebc49e5e6 Merge pull request #1022 from spicyj/multichild-throw
Refactor ReactMultiChild to not throw errors too
2014-02-13 21:51:52 -08:00
Ben Alpert
f8349f9614 Add formNoValidate and noValidate too 2014-02-13 21:50:17 -08:00
Ben Alpert
80cbdea144 [docs] Update supported attributes list
Fixes #1008.
2014-02-13 21:47:49 -08:00
Ben Alpert
1991e46f1a [docs] Capitalize all nav titles for consistency 2014-02-13 21:41:09 -08:00
Ben Alpert
b98f1adf1a Avoid innerText for better newline behavior
Fixes #1080.
2014-02-13 21:31:32 -08:00
Paul O’Shannessy
05ee61d763 Merge pull request #1084 from spicyj/jsx-wh
Various fixes to whitespace transformer
2014-02-13 21:10:49 -08:00
Ben Alpert
cc010e3287 Support transforming multiple files at once 2014-02-13 19:15:59 -08:00
Ben Alpert
49ddf905b1 Use graceful-fs to avoid EMFILE errors 2014-02-13 19:15:59 -08:00
Ben Alpert
ecfd0c1473 Run over *.jsx as well 2014-02-13 19:15:59 -08:00
Ben Alpert
4a76b52751 Resolve paths relative to pwd, not npm install dir 2014-02-13 19:15:59 -08:00
Ben Alpert
940c86964d Rename run to run.js to avoid not-found errors 2014-02-13 19:15:39 -08:00
Ben Alpert
ac1c90e864 Tweak whitespace README to show other change 2014-02-13 19:01:04 -08:00
Jason Bonta
47645854f9 un-revert textContent, support multi-line strings in modern browsers
reverts 23ab30ff87 because the issue it fixed doesn't seem to be a problem
anymore. textContent should be better for more things anyway, as the
original 309a88bcf6 indicates. It should be faster because innerText
requires layout.

This also allows us to use strings with newlines in our rendered output
and have confidence that they will render the same on subsequent
re-renders. This is especially useful for es6-style backtick multi-line
strings. This will be more consistent as textContent is supported almost
everwhere so we won't have differing behavior between webkit and
firefox.

see https://github.com/facebook/react/issues/1080
2014-02-13 18:21:35 -08:00
Josh Duck
acbba1ae67 Updates to perf
ReactDefaultPerf:

* Show times as float instead of string. This means they're sortable.
* Add count columns to all types and average to exclusive time.
* Include mountComponent where updateComponent time is measured.
* Increment count on _renderValidatedComponent instead of update.

ReactDefaultPerfAnalysis:

* Return counts with all summaries.
2014-02-13 18:21:17 -08:00
Cheng Lou
5c953a7bdd Remove aural CSS numerial styles from CSSProperties
Those styles are not implemented in known browsers.
2014-02-13 18:21:03 -08:00
Paul O’Shannessy
d1a337b9db Move jsx_whitespace_transform
Also add readme and more details to package.json so it can be published.
2014-02-13 15:58:19 -08:00
Paul O’Shannessy
1012b2ff4b Merge pull request #979 from jeffmo/jsx_whitespace_codemod_tool
jsx whitespace codemod utility
2014-02-13 15:03:11 -08:00
Pete Hunt
6573a726ba Merge pull request #1075 from spicyj/defperf
Measure root component render in ReactDefaultPerf
2014-02-13 10:49:19 -08:00
Pete Hunt
a5c518f69a Merge pull request #855 from syranide/onerror
Add onError to ReactDOMImg to complement onLoad
2014-02-13 10:48:57 -08:00
Pete Hunt
f02c3c07d3 Merge pull request #1067 from spicyj/sandbox-seamless
Add seamless and sandbox properties for iframe
2014-02-13 10:48:37 -08:00
Pete Hunt
b04df6335a Merge pull request #1069 from spicyj/gh-1028
Assert that event listeners are real functions
2014-02-13 10:48:20 -08:00
Pete Hunt
fff48c5921 Merge pull request #1076 from spicyj/button-warn
Don't warn about onChange for button inputs
2014-02-13 10:48:07 -08:00
Andreas Svensson
cda1d8c779 Add onError to ReactDOMImg to complement onLoad 2014-02-13 10:43:03 +01:00
Ben Alpert
6f305505a7 Remove old whitespace doc warning
This was fixed by #480.
2014-02-13 01:37:06 -08:00
Ben Alpert
cd87848b7d Don't warn about onChange for button inputs 2014-02-13 01:16:37 -08:00
Ben Alpert
55be7a71c5 Measure root component render in ReactDefaultPerf
Fixes #1074.
2014-02-13 00:59:02 -08:00
Ben Alpert
f37474b75b Merge pull request #1034 from nadeeshacabral/patch-1
Fixed sample code fence highlight
2014-02-12 23:23:49 -08:00
Ben Alpert
b0757c5182 Assert that event listeners are real functions
Fixes #1028.
2014-02-12 23:21:46 -08:00
Ben Alpert
d0502cf3c1 Add seamless and sandbox properties for iframe
Fixes #1057.
2014-02-12 21:06:43 -08:00
Pete Hunt
3895353326 [perf] Refactor ReactDefaultPerf and add DOM operation tracing
Split the summary functions into a separate module, and add the ability to view a lot of all DOM operations. Removed DOM timing since it was incorrect. Will potentially replace with a
dropped frame counter in the future.
2014-02-12 16:35:24 -08:00
Jason Bonta
5abcce5343 add lineClamp, vendor prefixes to CSSProperty.isUnitlessNumber 2014-02-12 16:35:09 -08:00
Pete Hunt
75b58d2ad2 [perf] Wasted time metrics
This logs DOM ops for a given reconcile. Based on which components rendered and which ones *actually* caused DOM updates we can find
opportunities to add shouldComponentUpdate() methods.
2014-02-12 16:34:37 -08:00
Pete Hunt
94ef6c51fb [perf] Better inclusive measurements
Inclusive time is still not that helpful w/o looking at what actually resulted in DOM ops. However, this is better than what we have today and will serve as a building block.

I blacklisted everything but composite components -- hopefully that's OK.
2014-02-12 16:34:24 -08:00
Pete Hunt
439bca78ed [perf] New ReactDefaultPerf
Simplified version of https://github.com/facebook/react/pull/962. More goodies coming soon since the inclusive time isn't very helpful right now.
2014-02-12 12:30:02 -08:00
Pete Hunt
9ac27cb551 Rewrite ReactTransitionGroup
The key idea here is that you're always rendering `this.state.children`, not
`this.props.children`. When combined with `cloneWithProps()` this means we can
keep them in the DOM as long as we want. We add new children and reactively
update existing ones using `setState()` inside of `componentWillReceiveProps()`
so `this.state.children` always has the latest versions of components. Since we
may be keeping old components around that are no longer in
`this.props.children` we need a way to figure out where they should be inside
of the combined `this.state.children` list.  `ReactTransitionChildMapping` does
this for us.

Based on that infrastructure we can build the interface we always wanted: enter
and leave lifecycle hooks.

When a component is added to the DOM, `componentWillEnter(callback)` gets
called. Call the callback when you're done animating and `componentDidEnter()`
will be called.

When a component is about to be removed from the DOM,
`componentWillLeave(callback)` gets called. Call the callback when you're done
animating and `componentDidLeave()` will be called and the component will
*actually* be removed from the DOM. It won't be removed until you call the
callback.

These also handle "concurrent" changes. If you "stack" enter/leaves of a single
component before the animation has completed, it will block out all of those
animations until the current animation completes, and then finally it will
animate 0 or 1 times to get itself into the desired current state. This is what
differentiates `componentWillEnter()` from `componentDidMount()`.

The next step would be to build `componentDidReorder()`.

I've built `ReactCSSTransitionGroup` which is identical to the old
`ReactTransitionGroup` and codemodded the callsites.
2014-02-12 12:29:58 -08:00
Pete Hunt
a6749a686f [perf] Change how ReactDefaultPerf is injected
ReactDefaultPerf should inject itself when require()'d. This continues to support the ?react_perf use case for logging on initial page load.
2014-02-12 12:29:00 -08:00
Pete Hunt
12ebf33f89 [perf] Measure flush time
This is so we can look at a given flush to determine total time spent in React vs DOM, and which components ended up generating DOM ops.
2014-02-12 12:28:20 -08:00
Pete Hunt
d547374847 [perf] Log DOM time
Log the time it takes to perform all DOM operations
2014-02-12 12:27:53 -08:00
Pete Hunt
756bd975b1 [perf] Measure exclusive render time
Piece of https://github.com/facebook/react/pull/962
2014-02-12 12:27:18 -08:00
Paul O’Shannessy
da587b15d5 Merge pull request #1046 from spicyj/errutils
Disable guarding in ReactErrorUtils
2014-02-12 09:48:10 -08:00
Pete Hunt
db6ff14e7d Update videos.md
There is a better video clip for the Meteor devshop
2014-02-11 22:57:56 -08:00
Ben Alpert
8f298fbd69 Disable guarding in ReactErrorUtils
With #1021 and #1022, I believe this makes it so React never wraps user code in a try/catch. I left in the calls to ReactErrorUtils.guard because it sounds like FB code finds them useful.
2014-02-11 17:10:57 -08:00
Paul O’Shannessy
49747347fb Merge pull request #1048 from spicyj/form-onreset
Add onReset event for forms
2014-02-11 14:42:15 -08:00
Ben Alpert
35d9286781 Refactor ReactMultiChild to not throw errors too
Missed these when I fixed up Transaction; with the exception of ReactErrorUtils, this should be everything.
2014-02-11 10:14:20 -08:00
Paul O’Shannessy
8cf5882447 Merge pull request #1021 from spicyj/close-finally
Set isInTransaction to false even if close throws
2014-02-11 09:27:09 -08:00
Paul O’Shannessy
3f243bc4f9 Merge pull request #1055 from spicyj/jsx-transformer-ie8
Disable source maps when defineProperty is missing
2014-02-11 09:20:29 -08:00
Sebastian Markbage
fc2805fe03 Add warnings when accessing properties/methods on unmounted components
This creates a membrane around the React component prototype. It warns if you
try to access properties on the component before it's unmounted. Before it's
mounted, it should be considered a descriptor and not an actual instance.

The workaround, for unknown types, is to access the constructor using
component.type which has static methods on it.
2014-02-11 09:13:03 -08:00
Ben Alpert
89bcecc76f Disable source maps when defineProperty is missing
Fixes #1053.
2014-02-11 00:10:06 -08:00
Cheng Lou
0f4cc6ee84 [Docs] Hide compiled js tab in jsx-compiler.html
Fixes #1049
2014-02-10 23:22:59 -08:00
Pete Hunt
25e56a4540 Update complementary-tools.md 2014-02-10 21:16:13 -08:00
Paul O’Shannessy
66b290c32f Merge pull request #1042 from adelevie/master
Small grammar fix in ReactComponent.js
2014-02-10 16:18:55 -08:00
Paul O’Shannessy
6e5956195d Remove references to autoflow, error wrapper
Fixes #1023
2014-02-10 14:39:57 -08:00
Pete Hunt
c544b01cad Delete useless shit in ReactMount
lol
2014-02-10 14:31:15 -08:00
Pete Hunt
5f1d4d7c14 ReactInjection
Consolidate everything we can inject in core into one place. Does not expose publicly -- this is an internal moving of shit around.
2014-02-10 14:30:59 -08:00
Paul O’Shannessy
c1c2dd9a89 Add noValidate and corresponding formNoValidate
Fixes #988
2014-02-10 12:01:28 -08:00
Paul O’Shannessy
acfef143ae Merge pull request #1045 from spicyj/srcdoc
Add HTML5 srcdoc property for iframes
2014-02-10 12:00:43 -08:00
Ben Alpert
30fd3a30b0 Add onReset event for forms
Test Plan:
Tested in Chrome and IE8.
2014-02-10 11:12:26 -08:00
Pete Hunt
2e17144ac0 Update complementary-tools.md 2014-02-10 10:37:59 -08:00
Ben Alpert
40547125f8 Add HTML5 srcdoc property for iframes 2014-02-09 21:03:37 -08:00
Pete Hunt
eb3d516f40 Update complementary-tools.md 2014-02-09 19:18:11 -08:00
Alan deLevie
1194a040f9 remove comma in comment 2014-02-08 19:26:36 -05:00
Alan deLevie
42e65ddb3e Small comment grammar fix in ReactComponent.js 2014-02-08 19:25:49 -05:00
Paul O’Shannessy
141f3a8ac8 Merge pull request #1040 from zpao/react-tools-revamp
react-tools revamp
2014-02-07 13:59:56 -08:00
Paul O’Shannessy
d00b11ef03 Remove React from react-tools package
All of this is provided by the react package now, so there's no point in having
it available in multiple places. We *may* go back on that in the future for
shipping test utils, but for the time being, this is better for all.
2014-02-07 13:59:19 -08:00
Paul O’Shannessy
463f940c7f Build react-tools package on build, upload to builds site 2014-02-07 13:59:18 -08:00
Paul O'Shannessy
26fb009e0c fix comment 2014-02-07 13:51:39 -08:00
Cheng Lou
9ae002503c Ensure a pooled class releases back into the pool an instance of that class
Also added tests for PooledClass.

Noticed that some places use `ReactReconcileTransaction.release(transaction)`, when `transaction` might be of another class, say `ReactServerRenderingTransaction` (still a Github PR). This catches that.
2014-02-07 13:51:14 -08:00
Paul O’Shannessy
b199de29a0 Cleanup jsx tasks
debug and release are now identical, so there's no need to have both.
2014-02-07 10:21:19 -08:00
Ben Alpert
bc27325d31 Merge pull request #1003 from rdworth/patch-1
Update tutorial.md to still have jQuery script tag in later code sample
2014-02-07 00:08:22 -08:00
Paul O’Shannessy
d8700f04da Actually upload react.tgz to builds server 2014-02-06 23:59:58 -08:00
Ben Alpert
721ac85bf8 Merge pull request #1039 from imagentleman/patch-2
Update broken link in "Why React" post
2014-02-06 21:18:56 -08:00
imagentleman
3141bc5084 Update broken link in "Why React" post
The AngularJS docs have been updated since the post was originally published.

It should point to the docs from that date (June 5th).
2014-02-06 23:41:48 -05:00
Ben Alpert
bc1e950a41 Merge pull request #1038 from imagentleman/patch-1
Docs: Fixed reference to unreachable url.
2014-02-06 20:40:47 -08:00
imagentleman
e9e44773ee Docs: Fixed reference to unreachable url. 2014-02-06 21:32:30 -05:00
Paul O’Shannessy
94d11ecf05 build npm-react module, upload to builds page 2014-02-06 15:06:10 -08:00
cpojer
71c10b9f45 Add PropTypes.ArrayOf and clean up ReactPropTypes.js 2014-02-06 11:28:51 -08:00
Nadeesha Cabral
5f941628e0 Fixed missing lighted line
The line number added had been changed from the previous representation of the code fence, but was not highlighted. Therefore, fixed.
2014-02-06 19:11:19 +05:30
Ben Alpert
497dab2ad9 Merge pull request #1033 from bripkens/tostring-docs
docs(ServerRendering): Reflect renderComponentToString changes
2014-02-05 22:59:13 -08:00
Ben Ripkens
4c1a737343 docs(ServerRendering): Reflect renderComponentToString changes 2014-02-06 07:56:37 +01:00
Pete Hunt
73b4f954f2 DOMIDOperations -> BackendIDOperations 2014-02-05 19:47:54 -08:00
Paul O’Shannessy
4ebdb2c0ac Merge branch 'spicyj-uncontrolled-select'
Closed #907
2014-02-05 16:42:32 -08:00
Paul O’Shannessy
e0262d50f9 Skip assignment, just call updateOptions directly 2014-02-05 16:41:57 -08:00
Paul O’Shannessy
647e65525c Center twitter embeds differently. again.
This time, just target the iframe. display: table was weird in webkit.
2014-02-05 16:25:13 -08:00
Paul O’Shannessy
8360da2937 Don't use <center> for twitter embeds 2014-02-05 15:51:06 -08:00
Jonas Gebhardt
2f812b6f9b Community Round-Up #15; center embedded tweets 2014-02-05 15:19:53 -08:00
Ben Alpert
c7dd8d4217 Refactor updateOptions to take value 2014-02-05 11:46:34 -08:00
Ben Alpert
9c5c1ed902 Make uncontrolled select not set value on update 2014-02-05 11:39:44 -08:00
Paul O’Shannessy
7ad28183b4 Merge pull request #1019 from petehunt/docs99
Update docs for React.Children
2014-02-05 11:37:38 -08:00
Paul O’Shannessy
2031946946 Re-add strict warning to Danger test
Lost in the great reorg
2014-02-05 11:01:29 -08:00
Paul O’Shannessy
b9cd2f0d3d Merge branch 'reorg' 2014-02-04 19:51:55 -08:00
Paul O’Shannessy
2435b66840 Fix version check test 2014-02-04 19:49:58 -08:00
Paul O’Shannessy
a528beeda9 Put ReactWithAddons in browser/ 2014-02-04 19:49:58 -08:00
Pete Hunt
1a39c3143c The great reorg of February 2014 2014-02-04 19:49:58 -08:00
cpojer
a21979404c Add canUseEventListeners to ExecutionEnvironment. 2014-02-04 15:09:41 -08:00
Pete Hunt
9730759322 Fix cloneWithProps() to allow overriding props
This is a clear bug.
2014-02-04 14:37:53 -08:00
Pete Hunt
945f788a41 React.Children helpers
Adds React.Children and map(), forEach() and only().
2014-02-04 14:37:44 -08:00
Paul O’Shannessy
8d1d29286a Merge pull request #1013 from bripkens/lint
Fix use strict warnings
2014-02-04 12:39:41 -08:00
Ben Alpert
17f602f924 Set isInTransaction to false even if close throws
If a transaction wrapper's closer throws (such as flushBatchedUpdates in ReactDefaultBatchingStrategy) then we still want to properly deinitialize the transaction by setting isInTransaction to false. Without this, we can't reuse the transaction object (in this case, all future batched updates would fail because nested transactions aren't allowed).
2014-02-04 12:03:29 -08:00
Pete Hunt
7aaa3a4ed1 Merge pull request #922 from spicyj/submit-submit
Fix double-binding to submit event
2014-02-04 10:25:34 -08:00
Pete Hunt
3642b6ea62 Merge pull request #982 from bripkens/async-tostring
fix(ServerRendering): execution should be async
2014-02-04 10:24:22 -08:00
Paul O’Shannessy
bced44533f Merge pull request #967 from syranide/noie8catch
Remove unnecessary catch-clauses for try-finally
2014-02-04 10:11:06 -08:00
Andreas Svensson
f9bb6e46f1 Remove unnecessary catch-clauses for try-finally 2014-02-04 18:07:34 +01:00
Ben Ripkens
e14555caed Use lowercase "string" so that the documentation complies with typecheckers 2014-02-04 09:05:52 +01:00
petehunt
aebfd641aa more references 2014-02-03 23:33:20 -08:00
petehunt
9e1c6950b1 update docs for React.Children 2014-02-03 23:28:49 -08:00
Ben Ripkens
220687abda Add new lines above use strict and keep directives at the top 2014-02-04 07:47:35 +01:00
Pete Hunt
0dc0b45f3c Merge pull request #1018 from stoyan/patch-2
joe -> la web speed
2014-02-03 22:31:23 -08:00
Stoyan
c8a2018228 Update videos.md 2014-02-03 22:09:00 -08:00
Paul O’Shannessy
19ff353fdd Merge pull request #975 from spicyj/transaction-no-catch
Refactor Transaction to not rethrow errors
2014-02-03 21:43:27 -08:00
Paul O’Shannessy
4992423547 Merge pull request #1005 from jjt/boolattr
Fix boolean attributes as per HTML5 spec
2014-02-03 18:17:46 -08:00
Ben Newman
6d4b470cfc Merge pull request #1016 from benjamn/revert-pure-cjs-until-0.9
Revert commits switching from browserify to pure-cjs (on hold until after v0.9 ships).
2014-02-03 16:09:37 -08:00
Ben Newman
9f1ed709d0 Revert "Switched from browserify to pure-cjs bundler."
This reverts commit bff9731b66.
2014-02-03 19:05:22 -05:00
Ben Newman
77c53dd5d4 Revert "More optimizations and fix for JSXTransformer build"
This reverts commit f1b7db9aef.
2014-02-03 19:05:15 -05:00
Ben Newman
e994e06c54 Revert "Removed redundant uglification"
This reverts commit 86373d924c.
2014-02-03 19:05:09 -05:00
Ben Newman
806e879566 Merge pull request #1002 from RReverser/pure-cjs
Switch from browserify to pure-cjs bundler.
2014-02-03 16:01:13 -08:00
Pete Hunt
fa046ca04e Merge pull request #963 from bobeagan/patch-1
Replace "comments.json" with this.props.url in the docs tutorial code snippet
2014-02-03 15:08:17 -08:00
azure provisioned user
86373d924c Removed redundant uglification
Removed uglification for separate files since it significantly slowed down build (browserify:min became 26 sec instead of 110, same for :addonsMin) while gave economy in ~70 bytes for min+gz version.
2014-02-03 22:06:38 +00:00
Cheng Lou
5dabba999b add missing 'use strict' to getTestDocument 2014-02-03 12:52:46 -08:00
Cheng Lou
57bf7d21f3 fix transaction comment from componentDidRender to componentDidUpdate 2014-02-03 12:52:36 -08:00
Ben Newman
ce95c3d042 [React] Don't attach to document in ReactTestUtils.renderIntoDocument. 2014-02-03 12:51:34 -08:00
Ben Ripkens
92fdc1562d Use strict in tests 2014-02-03 20:29:33 +01:00
Ben Ripkens
4e9352f8f8 Fix use strict warnings 2014-02-03 13:11:51 +01:00
Ben Ripkens
cd2aecc377 fix(ServerRendering): execution should be sync
The documentation states that React.renderComponentToString
'uses a callback API to keep the API async', but the
implementation is actually synchronous. In order to maintain
this contract the callback should always be called
asynchronously or be change to a synchronous API.

As per the discussion of pull request 982, the API should
be changed to a synchronous one.
2014-02-03 11:39:09 +01:00
Pete Hunt
85270ae154 Merge pull request #1012 from jaredly/patch-1
adding a link to react-router
2014-02-02 13:34:58 -08:00
Jared Forsyth
92a20220e7 adding a link to react-router 2014-02-02 01:23:12 -07:00
Pete Hunt
e4d1618f63 Update example-apps.md 2014-02-01 18:43:12 -08:00
Christopher Chedeau
78f3addd01 Merge pull request #1011 from petehunt/complementary-tools
Add a complementary tools page
2014-02-01 18:36:45 -08:00
Christopher Chedeau
036303ee90 Merge pull request #1010 from petehunt/meteorvid
Add link to meteor talk
2014-02-01 18:35:43 -08:00
petehunt
26c6ea961b add example apps page 2014-02-01 18:11:00 -08:00
petehunt
aaada5e212 Add a complementary tools page 2014-02-01 17:43:56 -08:00
Pete Hunt
f18bda51d6 Update videos.md 2014-02-01 17:01:52 -08:00
petehunt
3119d66e26 Add link to meteor talk 2014-02-01 17:01:19 -08:00
Ben Alpert
98432365d9 [docs] Fix comma splice 2014-01-31 22:30:38 -08:00
Ben Alpert
a2e805b26e Disable CodeMirror smart indentation
Fixes #966.
2014-01-31 22:10:37 -08:00
jjt
f7949c1c23 Fix boolean attributes as per HTML5 spec 2014-01-31 17:24:48 -08:00
Paul O’Shannessy
fce6d114fe Merge pull request #973 from syranide/hidethekill
Fix references to the old ReactID syntax
2014-01-31 15:33:57 -08:00
Ingvar Stepanyan
f1b7db9aef More optimizations and fix for JSXTransformer build
* Dropped dependency on emulation of Node.js native modules.
* Added deamdify step for JSXTransformer build.
2014-01-31 21:53:08 +02:00
Christopher Chedeau
f1b54bc310 s/Mock DOM/Virtual DOM/
Let's be consistent with the naming
2014-01-31 10:57:06 -08:00
Richard D. Worth
e58064a8db Update tutorial.md to still have jQuery script tag in later code sample 2014-01-31 12:13:52 -06:00
Ingvar Stepanyan
bff9731b66 Switched from browserify to pure-cjs bundler. 2014-01-31 18:25:09 +02:00
Sebastian Markbåge
1666935878 Merge pull request #1001 from kmeht/renderComponentDocs
Add documentation about React.renderComponent
2014-01-30 17:29:59 -08:00
Kunal Mehta
43a242b67f Add documentation about React.renderComponent
Recently learned that components passed into `React.renderComponent` may not be the ones actually mounted. Also learned that it returns the mounted component. Added some documentation describing this.
2014-01-30 17:14:59 -08:00
Josh Duck
5d7563f706 Fix warning for numeric properties
Number('.1') === 0.1, and react uses dot-prefixed keys
for children. Whoops. Nuke the non-numeric requirement, and just
check a regex. This seems performant enough in micro-benchmarks:
http://jsperf.com/numericlike
2014-01-30 16:54:01 -08:00
Pete Hunt
4cbc4b58f6 Support children and ref for cloneWithProps()
We're not handling these correctly.
2014-01-30 16:53:47 -08:00
Pete Hunt
b225b34f91 Merge pull request #985 from petehunt/remove-react-page
Remove references to react-page
2014-01-30 10:40:48 -08:00
Pete Hunt
32f69713fc Merge pull request #995 from Contra/patch-1
fix grammar mistake (reconciliation docs)
2014-01-30 10:40:28 -08:00
Eric Schoffstall
cf1089fa0e fix grammar mistake 2014-01-29 20:19:51 -07:00
Josh Duck
00f2a053f0 Warn for numeric object properties
Numeric keys will be ordered sequentially in Chrome/Firefox.

Warn the user if such keys are set on a child.
2014-01-29 14:08:23 -08:00
Ben Newman
65490a09e6 Use querySelectorAll instead of getElementsByName in ReactDOMInput.
We've been able to use `querySelectorAll` in all the browsers that we
support for some time now, but we haven't been able to test code that uses
it in the older version of `jsdom` that we were using, until recently.

Besides the general goal of modernizing our code, the impetus for this
specific change is that I'm trying to support testing without having to
render nodes into an actual document. The `.getElementsByName` method is
only defined on `document` and only works if the nodes you care about are
contained by the document.

On the other hand, `querySelectorAll` works on any DOM node, and allows a
more precise selection of just the `<input type="radio">` elements that
have the appropriate name.

IE8's implementation of `querySelectorAll` supports attribute-based
selectors, which is all we need here.
2014-01-29 14:08:21 -08:00
Paul O’Shannessy
d8e9eb978b Fix animation example code
key should never be index into an array or there are bugs. Especially in
transitions.

Fixes #853
2014-01-29 13:06:22 -08:00
Pete Hunt
46c6ac5bb0 Update 09.2-form-input-binding-sugar.md 2014-01-29 12:45:46 -08:00
Pete Hunt
132e8b3c43 Merge pull request #880 from jbaiter/reactlink_checkbox
Support two-way binding for checkboxes in LinkedValueMixin via 'checkedLink' property
2014-01-29 12:44:30 -08:00
Ben Alpert
4894055114 Fix docs typo 2014-01-29 11:19:45 -08:00
Josh Duck
b5dbbd5b2d Add warning about object property order.
It's easy to misuse the properties-as-keys feature and end up with children rendered out of order. Add a note and example of how to avoid this.
2014-01-29 10:53:21 -08:00
petehunt
470a7d11ee remove references to react-page 2014-01-28 16:02:16 -08:00
Ben Newman
34e6a51e19 Merge pull request #981 from benjamn/upgrade-commoner-to-remove-output-directory-locking
Upgrade Commoner to v0.9.0 to get rid of output directory locking.
2014-01-27 19:21:32 -08:00
Ben Newman
933681b42c Upgrade Commoner to v0.9.0 to get rid of output directory locking.
Closes #957.
2014-01-27 19:07:00 -08:00
Ben Newman
0bca41fc93 Merge pull request #980 from benjamn/issue-856-delete-build-modules
Remove build/modules/ at beginning of `grunt` and `grunt test`.
2014-01-27 18:01:18 -08:00
Ben Newman
864366d082 Remove build/modules/ at beginning of grunt and grunt test.
Little-known fact: instead of writing copies of compiled module files to
build/modules/, the bin/jsx-internal script actually just makes hard links
to the master versions of files in the .module-cache/, so re-populating
build/modules/ is very inexpensive.

Closes #856.
2014-01-27 16:46:01 -08:00
JeffMo
f368f18b61 jsx whitespace codemod utility 2014-01-27 13:08:36 -08:00
Ben Newman
36fd1def84 Move grunt/config/jsx/jsx.js to grunt/config/jsx.js.
There used to be more files in that subdirectory.
2014-01-27 12:09:55 -08:00
Paul O’Shannessy
0e5dfd3fec Merge pull request #964 from bobeagan/patch-2
fix incorrect link
2014-01-27 11:26:33 -08:00
Ben Alpert
d300df51e1 Refactor Transaction to not rethrow errors
Rethrowing errors makes debugging harder. This makes it so that an exception in a render method can be caught using the purple stop sign (or the blue one, of course) in Chrome.
2014-01-26 15:51:37 -08:00
Andreas Svensson
989eb2e7d9 Fix references to the old ReactID syntax 2014-01-26 21:26:58 +01:00
Pete Hunt
526be1570e Fix memory leak with renderComponentToString()
This is leaking memory. Move event registration to mount time.
2014-01-24 18:23:51 -08:00
Bob Eagan
e3342f31b2 add hash link for lifecycle section of working with the browser page 2014-01-24 16:46:09 -07:00
Bob Eagan
4aececb645 fix incorrect link 2014-01-24 11:10:16 -07:00
Bob Eagan
7614af3c9a replace "comments.json" with this.props.url 2014-01-24 08:52:00 -07:00
Pete Hunt
4975113f20 Merge pull request #958 from aymanosman/master
Fix typo
2014-01-24 03:38:14 -08:00
Jeff Morrison
ce92efefc0 Codemod for whitespace change
This codemods to shim any old-style JSX whitespace so that it renders the same as before.
Basically it sticks explicit `{' '}` spaces in where spaces are no longer implicit.
2014-01-23 13:52:38 -08:00
Paul Shen
4a5a6ad733 Transfer the key prop in cloneWithProps
`cloneWithProps` uses `ReactPropTransferer`, which ignores the `key`
prop. See https://github.com/facebook/react/pull/713

However, this is not the case with `cloneWithProps` because when someone
is cloning a component and provides a key, they mean for the clone to
take it.
2014-01-23 13:48:39 -08:00
Pete Hunt
62b52e008e Don't reconcile children unneccessarily
We've talked about this perf optimization for a while now. This prevents us from re-reconciling components that are above the component being
reconciled in the owner hierarchy.
2014-01-23 13:48:36 -08:00
Ben Newman
b1e6c4d0dd Merge pull request #959 from benjamn/commoner-multiple-file-support
Upgrade Commoner to v0.8.14 for multiple file support.
2014-01-23 13:10:17 -08:00
Jeff Morrison
db04043eaa Merge pull request #480 from syranide/whitespace
JSX whitespace coalescing rules
2014-01-23 12:32:57 -08:00
Ben Newman
1e702f7258 Upgrade Commoner to v0.8.14 for multiple file support.
See [Commoner's README.md](
https://github.com/benjamn/commoner#generating-multiple-files-from-one-source-module)
for further explanation of the new functionality.

Among other potential benefits, this upgrade allows us to generate source
maps as standalone files rather than appending them inline to every
compiled module file under `build/modules/` (see #833).
2014-01-23 15:25:20 -05:00
Ayman Osman
97518fd664 Fix typo 2014-01-23 19:21:20 +00:00
Paul O’Shannessy
38491c7c93 Merge pull request #952 from jeanlauliac/patch-1
Update broken link in 'why react' article
2014-01-23 09:40:28 -08:00
Johannes Baiter
ad9c5e9242 Use Simulate.click instead of Simulate.input for simulating input on
checkbox.
2014-01-23 10:53:36 +01:00
Johannes Baiter
91ef878ca8 Fix comparison in _handleLinkedCheckChange 2014-01-23 10:53:36 +01:00
Johannes Baiter
2521b47707 Fix typo in ReactDOMInput-test 2014-01-23 10:52:55 +01:00
Johannes Baiter
79995a05c7 Add invariant if both checkedLink and valueLink are provided 2014-01-23 10:52:54 +01:00
Johannes Baiter
7b047111a0 Support two-way binding for checkboxes in LinkedValueMixin via 'checkedLink' property 2014-01-23 10:49:02 +01:00
Jean Lauliac
b872100be6 Normalize internal links in 'why react' article 2014-01-22 22:01:20 +01:00
Jean Lauliac
14cb99c9aa Update broken link in 'why react' article 2014-01-22 21:53:36 +01:00
Andreas Svensson
c16b5659a0 Implement stricter whitespace rules 2014-01-22 21:00:10 +01:00
Pete Hunt
0af9c3ebe7 Merge pull request #748 from spicyj/private-getvalue
Change LinkedValueMixin to a util class
2014-01-22 10:54:13 -08:00
Ben Alpert
95a80591dd Change LinkedValueMixin to a util class
This makes it clear that .getValue() is not a public API.
2014-01-22 09:57:59 -08:00
Paul O’Shannessy
f0b01d0faa Merge pull request #885 from syranide/natext
Remove unnecessary 'NA'-fallback for getTextContentAccessor()
2014-01-21 17:22:48 -08:00
Paul O’Shannessy
1d1a790df0 Merge pull request #901 from syranide/80chars
Fix lines longer than 80 chars
2014-01-21 17:09:24 -08:00
cpojer
ca02a068b8 Update propTypes documentation. 2014-01-21 16:45:34 -08:00
cpojer
8b12670ef9 Perf Test for the propTypes change. 2014-01-21 14:05:38 -08:00
cpojer
2cac321b27 Change ReactPropTypes invariant's to console.warn. 2014-01-21 14:05:33 -08:00
Paul O’Shannessy
9c91546451 Merge pull request #918 from spicyj/npm-react-rec
Fix copying files to build/npm-react recursively
2014-01-21 13:03:57 -08:00
Paul O’Shannessy
494f6e9c34 Merge pull request #921 from spicyj/grunt-jsx-no-dev
Remove unused grunt jsx config options
2014-01-21 11:40:43 -08:00
Pete Hunt
e3248efe92 Merge pull request #934 from syranide/minid
Shortened generated "data-reactid"
2014-01-20 13:26:42 -08:00
Andreas Svensson
559cd46181 Shortened generated "data-reactid" 2014-01-20 22:03:25 +01:00
Ben Alpert
e931dba107 Merge pull request #731 from fabiomcosta/jsxtransform-filename
Adds filename to JSXTransform error messages
2014-01-20 12:18:37 -08:00
Fabio M. Costa
de7a92afa7 Updating error message to also show part of the code, making it easier to find the error 2014-01-20 11:57:35 -08:00
Fabio M. Costa
d829d1ab9b Adding current page's url for inline code and code improvement 2014-01-20 11:57:34 -08:00
Fabio M. Costa
b1a949ed45 Adds the filename to JSXTransform error message, making it easier to debug JSX syntax errors. 2014-01-20 11:55:17 -08:00
Cheng Lou
4b392f19a8 Merge pull request #861 from andrewdavey/unitless-css-props
Unitless css props
2014-01-17 21:49:24 -08:00
Ben Alpert
ffc31ed77b Merge pull request #914 from chenglou/jsx
tweak frontpage first example code
2014-01-17 18:27:51 -08:00
Paul O’Shannessy
df8d092609 Merge pull request #924 from zpao/update-deps
Update build dependencies
2014-01-17 18:01:43 -08:00
Paul O’Shannessy
ca930efa7c Upgrade (explicitly) grunt
They deprecated the use of some packaged modules and suggest using those modules
directly. http://gruntjs.com/blog/2013-11-21-grunt-0.4.2-released

Lodash was the only use we had.
2014-01-17 18:00:40 -08:00
Paul O’Shannessy
9558285f09 Update other dependencies 2014-01-17 18:00:40 -08:00
Paul O’Shannessy
c5f0e14985 Update browserify
Also update bundle.transform call site, which now takes options
2014-01-17 18:00:40 -08:00
Cheng Lou
d8d4120614 [docs] Tweak frontpage first example and jsx-compiler example 2014-01-17 17:53:44 -08:00
Ben Alpert
ea711f1d62 Simplify live editor execution logic 2014-01-17 17:42:53 -08:00
Ben Alpert
4440486a24 Properly clear live editor on JSX compile failure 2014-01-17 17:42:40 -08:00
Nick Thompson
0d2510ad9c Add span property to React DefaultDOMPropertyConfig
So that the `span` attribute on <colgroup> tags isn't swallowed by
React.
2014-01-17 17:17:31 -08:00
Tim Yung
79beb71d69 Fix ChangeEventPlugin Dependencies
When React moved to attaching top-level event listeners on-demand, not all of the dependencies for `ChangeEventPlugin` were set. This led to `onChange` events not firing under certain circumstances. For example, listening to `onChange` on a checkbox will not work because it relies on `onClick` (unless something else on the page was listening to `onClick`).
2014-01-17 17:17:31 -08:00
Cheng Lou
d489637a4f Merge pull request #931 from spicyj/master
Update homepage for new JSX/JS editor
2014-01-17 16:56:40 -08:00
Ben Alpert
2ac36178c6 Update homepage for new JSX/JS editor 2014-01-17 16:46:50 -08:00
Paul O’Shannessy
487f633643 Normalize line endings 2014-01-17 16:28:32 -08:00
Paul O’Shannessy
8abca77381 .gitattributes to ensure LF line endings when we should 2014-01-17 16:25:53 -08:00
Cheng Lou
71b585325c docs add jsx->js tab to live editors 2014-01-17 15:49:59 -08:00
Sebastian Markbåge
a05cef4a40 Merge pull request #852 from spicyj/no-store-mount-image
Don't store mount image on component instance
2014-01-17 15:44:57 -08:00
Cheng Lou
4f53f58754 docs fix back link in Examples 2014-01-17 15:21:49 -08:00
Paul O’Shannessy
ef4bda326e Merge pull request #822 from chenglou/setstate
better error for bad setState arguments and mergeHelpers
2014-01-17 13:05:06 -08:00
Pete Hunt
804280275b Merge pull request #928 from nick-thompson/componentWillMount-descrip
Clarify componentWillMount behavior
2014-01-17 12:46:47 -08:00
Nick Thompson
c2d57dff4b Clarify componentWillMount behavior 2014-01-17 12:44:21 -08:00
Ben Alpert
c72e906841 Fix double-binding to submit event
Fixes #916.
2014-01-17 03:00:08 -08:00
Ben Alpert
703a29c0b2 Remove unused grunt jsx config options
Since 5466d0a063, the `__DEV__` isn't used any more. I can't find anything that uses the `debug` flag either.
2014-01-17 02:02:47 -08:00
Ben Alpert
76a7e2de75 Fix copying files to build/npm-react recursively
The intention of the `npm-react/**/*` rule was to copy recursively but it would have flattened any nested directory structure. I changed the `build/modules` rule to copy recursively as well, which is necessary for `ReactTestUtils` to be able to require `test/mock-modules.js` successfully. (`ReactTestUtils` isn't included in a clean `npm-react` build currently but it will be in the future.)

This also makes running ART tests more practical.
2014-01-17 01:15:15 -08:00
Christopher Chedeau
2562813c63 Document isMounted
Text from @petehunt
2014-01-16 10:08:53 -08:00
Jeff Morrison
89819de4f2 Kill last remaining use of $ in React
It's only used here, so let's just inline this and get rid of the additional module.
Also it will make people like this guy happy: https://github.com/facebook/react/issues/900

(of course he might be even more happy if he wasn't using MS TFS....but that's a much bigger diff, and not one I can write...)
2014-01-15 16:46:11 -08:00
Alex Zelenskiy
b5f905523b Adding 'scope' to list of standard html attributes in react
scope is used for screen readers, so it would be nice to have. Documentation here: http://www.w3.org/TR/WCAG20-TECHS/H63
2014-01-15 16:44:28 -08:00
Isaac Salier-Hellendag
4bdea53d6e Add topContextMenu to the event dependencies for SelectEventPlugin 2014-01-15 16:43:41 -08:00
Christopher Chedeau
9ade3c26d3 Introduce PropTypes.shape
This diff introduces PropType.shape which lets you type an object. PropType.object was already defined and since it isn't a function I couldn't really overload the meaning to also accept a type list. Instead of doing hackery, I decided to name it `shape`.

An example where this could be used is style:

```
  propTypes: {
    style: PropTypes.shape({
      color: PropStyle.string,
      fontSize: PropTypes.number
    })
  }
```
2014-01-15 16:42:04 -08:00
Cheng Lou
0906d282ec throw when using component/component class as mixin
throw invariant error to help people new to mixins, so that they don't get misled into trying to mixin components into another component
2014-01-15 16:41:45 -08:00
Paul O’Shannessy
8ca62bd022 [docs] Remove commented out ghbtns 2014-01-15 11:40:36 -08:00
Paul O’Shannessy
a69f98b834 [docs] Add timezone to _config
This way we hopefully won't churn the feed when genereated in
a different time zone (eg France).
2014-01-15 11:14:15 -08:00
Paul O’Shannessy
e1f4357ff7 Remove stray "117", combine lines in polyfill docs 2014-01-15 11:08:10 -08:00
Pete Hunt
615dedc3e2 Merge pull request #881 from spicyj/checkbox-not-checked
"checkbox" not "checked"
2014-01-15 11:04:36 -08:00
Pete Hunt
94727f8223 Merge pull request #897 from spicyj/gh-208
Wrap _performComponentUpdate call in try/finally
2014-01-15 10:38:26 -08:00
Christopher Chedeau
a821f03cf4 Merge pull request #892 from rtfeldman/update-shim-docs
Mention need for `es5-sham.js` in docs
2014-01-15 09:15:59 -08:00
Andreas Svensson
fd02f2c1cd Fix lines longer than 80 chars 2014-01-15 15:19:14 +01:00
Richard Feldman
c3a2ea2256 Rewrite Older Browsers polyfill section for clarity. 2014-01-14 21:59:53 -08:00
Timothy Yung
977b60c1ed Fix "Uncontrolled Components" documentation 2014-01-14 21:13:27 -08:00
Ben Alpert
091534c376 Wrap _performComponentUpdate call in try/finally
Fixes #208. If you attempt a state update with a bad state then the render will fail (and the DOM won't change) but if you switch back to a valid state later then it'll rerender properly.
2014-01-14 20:30:07 -08:00
Pete Hunt
17de85689e Merge pull request #895 from spicyj/zomgperf
Make findComponentRoot faster with more nodeCache
2014-01-14 18:58:54 -08:00
Paul O’Shannessy
b131da3869 Merge pull request #884 from spicyj/tut-datatype
Add dataType to all $.ajax calls for consistency
2014-01-14 18:48:05 -08:00
Ben Alpert
d96c6914c7 Make findComponentRoot faster with more nodeCache
This is an alternative, less-invasive, fix for #891.

Test Plan:
On http://jsbin.com/OqOJidIQ/2/edit, got timings like

[75, 56, 30, 36, 27, 27, 28, 32, 27, 27, 28, 31]

instead of the old

[75, 729, 46, 32, 28, 34, 26, 27, 27, 30, 26, 26].

I also added a counter to getID and saw it was called 3014 times instead of the old 636264. (3014 is the number of nodes (3000) plus 3 calls that happen for the initial render and 1 for each of the 11 renders after that.)
2014-01-14 18:32:40 -08:00
Richard Feldman
f62ec225e0 Fix typo in docs. 2014-01-14 17:09:39 -08:00
Richard Feldman
9420e86480 Update docs to mention that you need both es5-shim.js and es5-sham.js to use React with IE8. 2014-01-14 16:57:27 -08:00
cpojer
c885abbf21 Allow null return values for functions to-be-merged. 2014-01-14 13:05:31 -08:00
Andreas Svensson
6c7697a1a9 Remove unnecessary 'NA'-fallback for getTextContentAccessor() 2014-01-14 11:41:23 +01:00
Ben Alpert
eb2ac7f2f2 Add dataType to all $.ajax calls for consistency
Fixes https://groups.google.com/forum/#!topic/reactjs/WWA3ZqU6y4w.
2014-01-13 19:54:09 -08:00
Pete Hunt
d9b959884b Merge pull request #878 from spicyj/mount-unmounted
Improve "Can only mount when umounted" message
2014-01-13 14:38:07 -08:00
Ben Alpert
5857eb884c "checkbox" not "checked"
I can only assume this was a typo.
2014-01-13 14:28:56 -08:00
Ben Alpert
2f027fce2d Improve "Can only mount when umounted" message 2014-01-13 13:26:24 -08:00
Isaac Salier-Hellendag
ad70848e80 Use fallback data for composition events if necessary 2014-01-13 13:15:17 -08:00
Pete Hunt
c6f91ee6e8 Merge pull request #864 from spicyj/transition-key-set-faster
Rewrite mergeKeySets to be O(n) instead of O(n^3)
2014-01-13 12:50:42 -08:00
Christoph Pojer
ca1ecc626b Merge pull request #876 from spicyj/cb-ctx
Always call callback in component context
2014-01-13 09:04:33 -08:00
Ben Alpert
1825f30353 Always call callback in component context
This brings these other call sites in line with line 67 of ReactUpdates.js:

callbacks[j].call(component);
2014-01-13 08:59:48 -08:00
Christoph Pojer
124096a9fe Fix #845, Trivial year change
This was accidentally pulled into gh-pages.
2014-01-13 08:56:20 -08:00
Christoph Pojer
ad6a982cd0 Fix #874: Edit thinking-in-react
Accidentally pulled #874 into gh-pages.
2014-01-13 08:51:29 -08:00
Cheng Lou
3d47177596 fix propTypes.any.weak test
accidentally copied over `.string.weak` and didn't change it
2014-01-12 20:47:16 -08:00
Pete Hunt
ddcab8be99 Merge pull request #871 from fernandoacorreia/jquery-mobile-example
jQuery Mobile React Example
2014-01-12 13:03:36 -08:00
Fernando Correia
425fd2ca08 jQuery Mobile React Example 2014-01-12 17:04:42 -02:00
Paul O’Shannessy
59cba3e9f7 Add missing semicolon I missed in #865 2014-01-11 23:29:35 -08:00
Paul O’Shannessy
6ebb1cb3ee Merge pull request #865 from jergason/link-to-docs-on-keys-warning
link to docs in unique key prop warning
2014-01-11 23:21:46 -08:00
Jamison Dance
972acb4581 link to docs in unique key prop warning 2014-01-11 22:17:06 -07:00
Paul O'Shannessy
2c335b0e57 Quieter devtools upsell
Check that we're not in a iframe before upselling.
2014-01-10 21:11:33 -08:00
Cheng Lou
d14ce00dc3 add React.PropTypes.any
add the ability for React propTypes to accept an `any` type: `someProp: React.PropTypes.any`.
This is more useful when combined with `.isRequired`, to enforce that _something_ is passed:
`someProp: React.PropTypes.any.isRequired`
2014-01-10 21:11:11 -08:00
Pete Hunt
d8a8f6a881 Upsell dev tools
People probably don't know these exist. Add some information about React
dev mode as well as a link to the developer tools when using Chrome.
2014-01-10 21:10:54 -08:00
Tim Yung
bcacd17f8b Better LinkedValueMixin Warning
Input elements of type `checkbox`, `hidden`, or `radio` can have a `value` without `onChange`. Also, if the input is `disabled`, who cares that it doesn't have an `onChange`?
2014-01-10 21:10:01 -08:00
Tim Yung
f71dbab31a Fix Undefined ownerDocument Fatal in IE8
This fixes a JS fatal in IE8 when `topLevelTarget.ownerDocument` is sometimes undefined.
2014-01-10 21:07:23 -08:00
Tim Yung
73d9d286ee Fix EnterLeaveEventPlugin Test in jsdom
This is a follow-up to #803.

In jsdom (used for internal testing), `<iframe>` does not properly create a default document. This makes the `EnterLeaveEventPlugin` tests work for jsdom, too.

Open source does not need this because it uses PhantomJS.
2014-01-10 21:04:39 -08:00
Paul O’Shannessy
49d6d2169d Remove trailing whitespace 2014-01-10 21:04:39 -08:00
Ben Alpert
1efb14bcf6 Rewrite mergeKeySets to be O(n) instead of O(n^3) 2014-01-10 15:31:15 -08:00
Andrew Davey
d6afb5285e CSS column-count property is unitless 2014-01-10 19:12:58 +00:00
Pete Hunt
979ee27e2b Merge pull request #862 from cpojer/docs-proptypes
Document PropTypes.renderable and PropTypes.component
2014-01-10 09:55:19 -08:00
cpojer
d73f80ecb2 Document PropTypes.renderable and PropTypes.component 2014-01-10 09:36:22 -08:00
Andrew Davey
423380f9c3 Unitless CSS flex properties 2014-01-10 11:16:06 +00:00
Andrew Davey
b70c3ef4bb Refactor unit test 2014-01-10 11:16:06 +00:00
Andrew Davey
ac0373ccae More unitless CSS properties
volume, stress, pitch-range, richness
2014-01-10 11:16:06 +00:00
Andrew Davey
095eea3241 CSS widows property is unitless
Ref #836
2014-01-10 11:16:05 +00:00
Timothy Yung
338ce603f9 Merge pull request #797 from spicyj/should-update
Fix cases where owner warning is shown
2014-01-09 18:50:21 -08:00
cpojer
95cb79a93e Remove CallbackRegistry 2014-01-09 16:58:48 -08:00
cpojer
b713c2c696 Add PropTypes.component to demand a single React component. 2014-01-09 16:58:47 -08:00
Ben Alpert
f5a48f1ff4 Fix cases where owner warning is shown
In b0431a5 I added the check in the wrong place which could cause the warning to be shown because of key changes rather than owner changes like the warning suggests.
2014-01-09 16:48:58 -08:00
Timothy Yung
f47238be41 Merge pull request #803 from spicyj/gh-788
Use proper window object for iframe in enter/leave
2014-01-09 16:35:07 -08:00
Timothy Yung
851f08bdc2 Merge pull request #780 from syranide/newhasevent
Further cleanup of isEventSupported
2014-01-09 16:34:57 -08:00
Timothy Yung
68bac7fbf0 Merge pull request #778 from syranide/flipwheel
Fix WheelEvent incorrectly flipping sign of deltaY
2014-01-09 16:34:47 -08:00
Timothy Yung
dea6063dc9 Merge pull request #771 from spicyj/gh-694
Don't get selection if no active element
2014-01-09 16:34:27 -08:00
cpojer
8dbc530d1c Add --harmony option to jsx. 2014-01-09 15:21:48 -08:00
Paul O’Shannessy
1f5c8d21d8 Merge pull request #786 from spicyj/gh-781
Fix potential memory leak when unmounting
2014-01-09 13:08:07 -08:00
Timothy Yung
2c93cd0267 Merge pull request #640 from spicyj/immutable-props-2
Don't mutate passed-in props, take 2
2014-01-09 12:52:58 -08:00
Christopher Chedeau
e3e3b477d3 Merge pull request #850 from spicyj/docs-ref-unmount
Document return value of unmountComponentAtNode
2014-01-09 09:21:39 -08:00
Ben Alpert
4d3a9c87d1 Don't store mount image on component instance 2014-01-08 22:53:59 -08:00
Ben Alpert
87a95155be Document return value of unmountComponentAtNode 2014-01-08 21:56:59 -08:00
Cheng Lou
3c40fb2e01 better error message for mergeHelpers and setState 2014-01-08 21:56:48 -08:00
Ben Alpert
2716f38861 Spy on purgeID instead of unmountIDFromEnvironment 2014-01-08 21:48:48 -08:00
Ben Alpert
e2f094614f Fix potential memory leak when unmounting
Fixes #781.
2014-01-08 21:43:52 -08:00
Paul O’Shannessy
09011493c5 Merge pull request #718 from syranide/npmenvify
Fix npm react having wrong version dependency for envify
2014-01-08 15:33:59 -08:00
Paul O’Shannessy
0c3628cd8d Merge pull request #757 from spicyj/ng
Don't tack on EventPluginHub globally
2014-01-08 15:23:47 -08:00
Ben Alpert
1db788b62c Don't tack on EventPluginHub globally 2014-01-08 15:20:05 -08:00
Christopher Chedeau
2052caf0cc Merge pull request #846 from spicyj/docs-nomin
Remove two more react.min.js references
2014-01-08 11:45:25 -08:00
Ben Alpert
76a0a9cba7 Remove two more react.min.js references 2014-01-08 11:40:53 -08:00
Paul O’Shannessy
46f7163f62 Don't use the min build in getting started guide 2014-01-08 11:38:34 -08:00
Paul O’Shannessy
8d0885e0d8 Merge pull request #844 from xixixao/patch-1
Fix URL in displayName description
2014-01-08 11:24:55 -08:00
Michal Srb
b4f4f10478 Fix URL in displayName description 2014-01-08 14:55:27 +01:00
Paul O'Shannessy
23ab30ff87 Revert textContent
Reverts 309a88bcf6 because this is causing
issues internally. I'll try to get a repro soon.
2014-01-07 21:10:03 -08:00
Pete Hunt
b1597ab2d7 Warn for common forms misuse 2014-01-07 21:08:13 -08:00
Paul O’Shannessy
be42d94f12 Don't set max_line_length for *.md 2014-01-07 20:46:46 -08:00
Jeff Morrison
33fe8eebda Merge pull request #799 from spicyj/display-name
Add display name in more cases
2014-01-07 12:58:23 -08:00
Ben Alpert
f0fdabae7b Add display name in more cases 2014-01-07 09:36:47 -08:00
Ben Alpert
a2ecee5353 Use proper window object for iframe in enter/leave
Fixes #788.
2014-01-07 08:36:42 -08:00
Ben Alpert
657602135c Don't mutate passed-in props, take 2 2014-01-06 21:42:04 -08:00
Ben Newman
4f57515f91 Fix some odd spacing inconsistencies in ReactRenderDocument-test. 2014-01-06 21:13:25 -08:00
Sebastian Markbåge
59bd45d594 Merge pull request #772 from spicyj/gh-444
Set event type on enter/leave events
2014-01-06 20:10:26 -08:00
Sebastian Markbåge
c28e1f24df Merge pull request #768 from spicyj/findcomponentroot-err
Remove sometimes-confusing console error
2014-01-06 18:57:18 -08:00
Tom Occhino
ba6c82a326 Merge pull request #829 from spicyj/transitiongroup-null-child
Make ReactTransitionGroup work with a null child
2014-01-06 18:40:35 -08:00
Timothy Yung
e23c06a60c Merge pull request #773 from spicyj/select-event-ff
Check for selection on keyup instead of deferring
2014-01-06 18:40:20 -08:00
Pete Hunt
70a0746e9f Fix react tests 2014-01-06 18:35:54 -08:00
Pete Hunt
1e980a146f Fix bug in cloneWithProps() 2014-01-06 18:35:54 -08:00
Pete Hunt
57f208e402 Merge pull request #821 from subtleGradient/subtlegradient/perf-task
benchmark runner & comparison tool with grunt commands and travis integration
2014-01-06 18:32:51 -08:00
Paul O’Shannessy
f9551d709e Merge pull request #808 from spicyj/prefer-textContent
Prefer textContent to innerText
2014-01-06 18:08:38 -08:00
Ben Alpert
c75899f277 Make ReactTransitionGroup work with a null child 2014-01-06 17:40:50 -08:00
Ben Alpert
09c8ec51bf Check for selection on keyup instead of deferring
This is essentially what we do for the change event in IE8 and IE9 already.
2014-01-06 16:37:27 -08:00
Paul O’Shannessy
6fdf36af13 Merge pull request #827 from spicyj/jstransform-202
Bump jstransform version to 2.0.2
2014-01-06 16:26:42 -08:00
Ben Alpert
5968571952 Bump jstransform version to 2.0.2
Necessary for JSXTransformer.js to work after 7675611.
2014-01-06 16:25:05 -08:00
Christopher Chedeau
e9484adf65 Merge pull request #774 from spicyj/img-onload
Add support for onLoad event to <img />
2014-01-06 16:24:25 -08:00
Ben Alpert
fb858a8fc2 Set event type on enter/leave events
Fixes #444.
2014-01-06 16:21:46 -08:00
Sebastian Markbåge
4f09a54a1d Merge pull request #741 from spicyj/flatten-nonull
Don't return null children from flattenChildren
2014-01-06 16:21:34 -08:00
Timothy Yung
8f2509e169 Merge pull request #789 from spicyj/gh-785
Set target properties explicitly for enter/leave
2014-01-06 16:16:35 -08:00
Ben Alpert
79c9025f17 Add support for onLoad event to <img /> 2014-01-06 16:16:21 -08:00
Christopher Chedeau
9454282bfc Merge pull request #819 from mtharrison/add-more-svg-tags
Added support for 4 extra SVG tags
2014-01-06 15:44:15 -08:00
Paul O’Shannessy
147506a911 Merge pull request #826 from spicyj/invariant-license
Add back license header to invariant
2014-01-06 15:36:37 -08:00
Ben Newman
b7b4bcfd2e Merge pull request #764 from spicyj/browser-source-maps
Add source map support to browser transformer.
2014-01-06 14:38:00 -08:00
Ben Alpert
808f60f8a0 Add back license header to invariant 2014-01-06 14:19:23 -08:00
Matt Harrison
bd575eb7c8 Updated getMarkupWrap.js to include the new SVG elements 2014-01-06 21:48:40 +00:00
Paul O’Shannessy
c2be8ba42d Sync vendored modules from upstream 2014-01-06 11:55:37 -08:00
Timothy Yung
627d7eb669 Merge pull request #754 from spicyj/over-and-out
Add onMouseOver and onMouseOut events
2014-01-06 10:28:54 -08:00
Tim Yung
182a237fa7 Separate Module for Key Normalization
This moves key normalization into its own module so that it can be re-used elsewhere.
2014-01-06 10:07:49 -08:00
Christoph Pojer
22ba8b67f1 Silence console.error in ReactDOMInput-test
This test is expected to throw but because of ReactErrorUtils.guard
which uses console.error in __DEV__ it also logged the invariant error
to the console. This change fixes it by temporarily stubbing out
console.error.

Fixes #531
2014-01-06 10:07:49 -08:00
Tim Yung
e65726cd04 Cleanup ReactEventEmitter Variable Naming
Minor follow-up to 80d7d2d0f8.
2014-01-06 10:07:49 -08:00
Isaac Salier-Hellendag
1584aaf746 Change global to window in SyntheticClipboardEvent
Replace `global` reference with `window` in `SyntheticClipboardEvent`.
2014-01-06 10:07:49 -08:00
Pete Hunt
089a494a1f Forbid full-page rendering without server rendering
Final part of server rendering cleanup. We should only support full-page rendering when server rendering is involved since
otherwise it's slow and can crash browsers when you start adding and removing document roots. This diff removes the magic
innerHTML code (since that will be handled by the server rendering piece) and adds the right assertions and errors.

Because there's no longer a dangerous of accidentally nuking the whole page, I removed allowFullPageRender which is yet another
internal we no longer need to expose.
2014-01-06 10:07:48 -08:00
Pete Hunt
9b3342ed34 Throw when unmounting <html>, <head>, <title> or <body>
These are dangerous from a cross-browser perspective. I think supporting efficient reactive updates will be prohibitively
expensive and we'll never prioritize it. Instead of killing this capability entirely, let's just throw on the dangerous cases.
There will be a few follow-up diffs
2014-01-06 10:07:48 -08:00
Christopher Chedeau
7630e56971 Merge pull request #804 from spicyj/examples-no-browserify
Remove mentions of browserify in examples
2014-01-06 10:03:10 -08:00
Christopher Chedeau
9cce0c2752 Merge pull request #823 from spicyj/key-docs
Add charCode/keyCode/which to key event docs
2014-01-06 09:40:18 -08:00
Thomas Aylott
91821007ed benchmark runner 2014-01-06 12:26:40 -05:00
Christopher Chedeau
6dd62b0e4f Merge pull request #688 from vjeux/community_14
Community Round-up #14
2014-01-06 09:11:09 -08:00
Matt Harrison
42262f5361 Aphabetized and wrapped tags/attributes docs 2014-01-06 08:15:46 +00:00
Timothy Yung
2c1a25411f Merge pull request #747 from spicyj/currentTarget
Set currentTarget on synthetic events
2014-01-05 20:41:48 -08:00
Timothy Yung
13230a3044 Merge pull request #643 from spicyj/scroll-pos
Fix scrollLeft/scrollTop warning in latest Chrome
2014-01-05 20:41:35 -08:00
Ben Alpert
b366e36367 Add charCode/keyCode/which to key event docs 2014-01-05 21:24:17 -07:00
Christopher Chedeau
ed3d5add76 Merge pull request #809 from passy/patch-1
Add gulp-react to Helpful OSS Projects
2014-01-05 18:16:20 -08:00
Christopher Chedeau
0e5b62a4c3 Merge pull request #818 from Daniel15/link-htmltojsx
Add link to HTML to JSX converter to “JSX In Depth” page
2014-01-05 18:16:06 -08:00
Cheng Lou
5b43a2e6d7 throw error when setState's arguments are bad 2014-01-05 18:01:07 -08:00
Matt Harrison
c01f0a0487 Updated docs with new SVG elements 2014-01-05 12:18:30 +00:00
Matt Harrison
c4d918aca0 Added support for 4 extra SVG tags: stop, defs, linearGradient, radialGradient 2014-01-05 11:17:04 +00:00
Daniel Lo Nigro
ae9188db50 Change “not allowed” back to “discouraged” since you technically *can* use props called class or for 2014-01-04 23:33:02 -08:00
Daniel Lo Nigro
202a3f184d Add link to HTML to JSX converter to “JSX In Depth” page 2014-01-04 23:25:28 -08:00
Christopher Chedeau
605b42e622 Merge pull request #811 from xixixao/issue793
Document displayName
2014-01-04 10:41:56 -08:00
xixixao
ee0a4acfac Document displayName 2014-01-04 17:34:16 +01:00
Pascal Hartig
e92d769a50 Add gulp-react to Helpful OSS Projects
Add @sindresorhus' JSX task for Gulp to the "Helpful Open-Source Projects" section of the tooling integration docs.
2014-01-04 11:20:45 +01:00
Ben Alpert
33dcf8a0b5 Set currentTarget on synthetic events
Fixes #658, fixes #659.
2014-01-04 00:27:11 -07:00
SanderSpies
80d7d2d0f8 Listen to events on demand
Fixes #381

This is a squashed version of https://github.com/facebook/react/pull/462
2014-01-03 23:09:59 -08:00
Ben Alpert
309a88bcf6 Prefer textContent to innerText
Fixes #807.
2014-01-04 00:01:03 -07:00
Pete Hunt
a575e93ecd Merge pull request #806 from spicyj/patch-4
Fix typo
2014-01-03 22:19:35 -08:00
Ben Alpert
ea40a6aedd Fix typo 2014-01-03 23:19:04 -07:00
Pete Hunt
047e962a55 Merge pull request #805 from spicyj/docs-mention-react-art
Mention react-art where we talk about SVG
2014-01-03 22:17:51 -08:00
Ben Alpert
fdfd7c1853 Mention react-art where we talk about SVG 2014-01-03 23:15:50 -07:00
Ben Alpert
be75e3be66 Remove mentions of browserify in examples 2014-01-03 22:58:51 -07:00
Timothy Yung
c11d6d79f5 Merge pull request #721 from spicyj/change-bubble-ie
Make controlled components and bubbling work in IE
2014-01-03 18:10:16 -08:00
Nick Thompson
d270e2b1c7 Don't add displayName in transform if already defined
This ensures we don't add displayName in the transform if it's already been
defined. This is especially important when in strict mode, where duplicate
properties in an object is an exception.
2014-01-03 16:07:10 -08:00
Christopher Chedeau
e3e24500ae Merge pull request #795 from philix/master
Add jsx-requirejs-plugin to the tooling-integration page
2014-01-03 11:09:59 -08:00
Felipe Oliveira Carvalho
86f2dbe55d Remove the require-jsx plugin from the tooling-integration page
In favor of the r.js friendly jsx-requirejs-plugin
2014-01-03 16:03:42 -03:00
Felipe Oliveira Carvalho
344b5998a8 Add jsx-requirejs-plugin to the tooling-integration page 2014-01-03 15:45:03 -03:00
Andreas Svensson
4de2d39f63 Fix WheelEvent incorrectly inverting sign of deltaY 2014-01-03 19:09:09 +01:00
Andreas Svensson
7264cbcdfb Further cleanup of isEventSupported 2014-01-03 19:02:20 +01:00
Jeff Morrison
1b67ac90f2 Make sure the mock is cleared in the EventEmitter test 2014-01-02 20:09:50 -08:00
Isaac Salier-Hellendag
29190a2c79 Support clipboardData in IE
Use the `clipboardData` object available on `window`, if it's not available on the event object. This allows us to support including the `clipboardData` in cut/copy/paste events in IE.
2014-01-02 20:05:07 -08:00
Christoph Pojer
bcfb476366 More tests for 77697f26e3 2014-01-02 20:05:03 -08:00
Ben Newman
1ee7f8131c Let components specify tag for ReactTestUtils.mockComponent to use.
If you're writing a test that involves a mocked component that normally
returns a `<li>` tag from its `render` method as the root element, mocking
it with a dummy `<div>` probably won't work, so you'll want to set

  MyListItemComponent.mockTagName = 'li';

The change to the `.mockImplementation` line makes sense because
`ConvenienceConstructor` is more or less synonymous (for these purposes)
with the wrapper that was previously used:

  function() {
    // This `this` used to be `null`, technically, but
    // ConvenienceConstructor doesn't pay attention to `this` anyway.
    return ConvenienceConstructor.apply(this, arguments);
  }
2014-01-02 20:03:55 -08:00
Ben Newman
a00e4c840c Support ReactTestUtils.mockComponent. 2014-01-02 20:03:40 -08:00
Sebastian Markbage
cbefc5a968 Add display names to controlled components
These show up as Unknown in the DevTools. They also wrap a native component,
so they show up double.
2014-01-02 20:03:26 -08:00
Fabio Costa
f3e774559f adding warning about the lack of support for onScroll on IE8
Adding `console.warn` about the lack of support for `onScroll` event on IE8
Related to this issue on github https://github.com/facebook/react/issues/631
2014-01-02 20:01:33 -08:00
Pete Hunt
1733d42ded Rework ReactRootIndex generation
This had a higher probability of collision than originally thought (bad math). This makes the strategy injectable and provies a
no-collision version on the client and an unlikely-to-collide version on the server.
2014-01-02 20:00:30 -08:00
Pete Hunt
cc005668b5 cloneWithProps()
what if you want to change the props of a child? This is my first attempt which lets you clone a child and transfer some custom props to it.

There is a fundamental issue with refs here. Since the component is cloned the ref will be broken. And since we can clone multiple times, it might not make sense to support repairing refs.
2014-01-02 19:46:50 -08:00
Pete Hunt
5661d5168e Add svg polygon 2014-01-02 19:45:55 -08:00
Ben Alpert
fb8277c819 Set target properties explicitly for enter/leave
Fixes #785.
2014-01-02 17:03:11 -07:00
Ben Newman
5aae5a7b1d Merge pull request #783 from benjamn/upgrade-commoner
Upgrade commoner build tool to v0.8.12.
2014-01-02 12:09:26 -08:00
Christopher Chedeau
acf0c5c646 Merge pull request #784 from vjeux/react_dev_tools
React Chrome Developer Tools
2014-01-02 12:04:53 -08:00
Vjeux
e915294b68 React Chrome Developer Tools 2014-01-02 21:04:09 +01:00
Ben Newman
1755d43add Upgrade commoner build tool to v0.8.12.
Fixes #394.
Fixes #615.
2014-01-02 14:54:13 -05:00
Ben Newman
04ad3bfcc3 Merge pull request #725 from cpojer/getInitialState-invariant
Add invariant to check getInitialState return value. Fixes #397.
2014-01-02 06:59:50 -08:00
Christopher Chedeau
a78f6f7f94 Merge pull request #779 from chenglou/live-err
docs better error display for live editor and JSX compiler
2014-01-01 19:58:26 -08:00
Cheng Lou
f0b5219df9 docs better error display for live editor and JSX compiler 2014-01-01 19:41:08 -05:00
Christopher Chedeau
3396654a6f Merge pull request #775 from chenglou/doc-fix
docs tips fix small typo and code
2014-01-01 14:05:21 -08:00
Cheng Lou
e244df510d docs tips fix small typo and code 2014-01-01 15:28:44 -05:00
Ben Alpert
7a9e5443b7 Don't get selection if no active element
Fixes #694.

Previously, it could be that there was an active element that was removed in between mousedown and mouseup.
2013-12-31 17:27:05 -07:00
Ben Alpert
261926303d Remove sometimes-confusing console error
Fixes #767. This essentially reverts 738de8c.

We could store some sort of flag to silence the console error here but since we've made significant improvements in markup wrapping, this error is fairly rare now. We'll also have validation of node structure soon in #735.
2013-12-31 13:37:15 -07:00
Christopher Chedeau
e91a8a1bc3 Merge pull request #765 from spicyj/editorconfig-80
.editorconfig: Set line length to 80
2013-12-31 12:22:14 -08:00
Ben Alpert
3defe88192 .editorconfig: Set line length to 80
And alphabetize properties.
2013-12-31 12:59:06 -07:00
Ben Alpert
7675611e5f Add source map support to browser transformer 2013-12-31 12:03:34 -07:00
Pete Hunt
9a4f011f6c Merge pull request #763 from spicyj/gh-762
Add info about dev vs. prod builds
2013-12-31 09:57:10 -08:00
Ben Alpert
c877451887 Add info about dev vs. prod builds
Also moved the dev builds first because that's what most people will want.
2013-12-31 10:35:49 -07:00
Christopher Chedeau
96782fc836 Merge pull request #755 from spicyj/cm-scroll
Upgrade codemirror and enable line wrapping
2013-12-30 20:56:59 -08:00
Christopher Chedeau
1155aa9ac0 Merge pull request #758 from chenglou/docs-kill-wiki
docs remove link to wiki page
2013-12-30 20:40:05 -08:00
Cheng Lou
41526091a0 docs remove link to wiki page
Also some minor writing changes.
2013-12-30 23:38:01 -05:00
Ben Alpert
b2e51c6e01 Upgrade codemirror and enable line wrapping
Fixes #678.
2013-12-30 18:06:00 -07:00
Ben Alpert
a2e352ea76 Add onMouseOver and onMouseOut events
Fixes #340.

Test Plan:
Ported @danielstocks's jsfiddle (linked in the issue) to React and the hover effect worked properly.
2013-12-30 17:38:15 -07:00
Christopher Chedeau
55b7a57e07 Merge pull request #753 from vjeux/virtual_dom_docs
Making 'native DOM' nodes more explicit in documentation
2013-12-30 16:37:51 -08:00
Vjeux
1d4d1a0be6 Making 'native DOM' nodes more explicit in documentation 2013-12-31 01:34:42 +01:00
Christopher Chedeau
7dca85a9b1 Merge pull request #752 from spicyj/docs-ie8-css
IE8 style fixes
2013-12-30 16:24:26 -08:00
Ben Alpert
1c90172cd0 IE8 style fixes
- Add html5shiv so that HTML5 elements like header, footer, etc can be styled
- Remove a couple uses of :first-child/:last-child which IE8 doesn't support
2013-12-30 17:17:17 -07:00
Christopher Chedeau
f871147b4d Merge pull request #750 from chenglou/docs-clean
docs tips small refactorings
2013-12-30 15:12:43 -08:00
Cheng Lou
1671efb53a docs tips small refactorings 2013-12-30 17:54:41 -05:00
Christopher Chedeau
8915f1b85d Merge pull request #749 from spicyj/docs-ie8
Make React website work in IE8
2013-12-30 14:28:19 -08:00
Ben Alpert
92b440b1d7 Make React website work in IE8
Fixes #406.

Empty conditional comment is for http://www.phpied.com/conditional-comments-block-downloads/.
2013-12-30 15:25:26 -07:00
Christopher Chedeau
3b0f705658 Merge pull request #623 from chenglou/tips-communication
docs tips parent-child communication 2
2013-12-30 14:09:01 -08:00
Cheng Lou
23eac0bbbb docs tips expose component function 2013-12-30 17:07:24 -05:00
Christopher Chedeau
50d190f111 Merge pull request #746 from petehunt/tip-update
Update parent/child communication tip
2013-12-30 10:23:19 -08:00
petehunt
47fe931549 Update parent/child communication tip 2013-12-30 13:22:10 -05:00
Paul O’Shannessy
b3e1697aad Merge pull request #739 from jhiswin/master
live_editor.js using deprecated function

Fixes #738 #666
2013-12-30 10:04:51 -08:00
Christopher Chedeau
4190d0a7bb Merge pull request #687 from vjeux/community_13
Community Round-up #13
2013-12-30 09:28:13 -08:00
Vjeux
40e2d8a064 Community Round-up #13 2013-12-30 18:27:31 +01:00
Ben Alpert
e1ec9a6c65 Don't return null children from flattenChildren
This simplifies ReactMultiChild a little bit and will make it more practical to coalesce adjacent text strings.
2013-12-29 12:19:10 -07:00
jhiswin
e2ebbeac07 live_editor.js using deprecated function
unmountAndReleaseReactRootNode -> unmountComponentAtNode
breaks html-jsx.html
2013-12-29 09:42:35 -05:00
Pete Hunt
eab2ededdf Merge pull request #736 from spicyj/minify-before-browserify
Minify both before and after browserify
2013-12-28 23:17:52 -08:00
Pete Hunt
7e29f4607b Merge pull request #737 from spicyj/docs-ajax-state
Move initial $.ajax out of getInitialState
2013-12-28 23:17:34 -08:00
Ben Alpert
cce91611aa Move initial $.ajax out of getInitialState
We want to encourage people to make pure getInitialState functions.
2013-12-29 00:14:05 -07:00
Ben Alpert
76c9d8465e Switch to using uglifyify 2013-12-29 00:03:26 -07:00
Ben Alpert
abee8b0476 Minify both before and after browserify 2013-12-28 23:41:54 -07:00
Pete Hunt
82c4e897dc Merge pull request #733 from ivan/master
Use explicit $.ajax dataType and add error callback
2013-12-28 22:15:08 -08:00
Ivan Kozik
17f14d523b console.log -> console.error 2013-12-29 06:12:45 +00:00
Pete Hunt
f5f464b16a Merge pull request #734 from ivan/tut-jsx-header
Tell user to keep the @jsx declaration at the top of the script
2013-12-28 22:08:19 -08:00
Ivan Kozik
0647c2ee98 Add a warning about the @jsx declaration 2013-12-29 05:51:07 +00:00
Ivan Kozik
f03d6e212a Use explicit $.ajax dataType and add error callback 2013-12-29 05:32:46 +00:00
Pete Hunt
918c5134e1 Merge pull request #732 from chenglou/doc-pragma
docs add warning to add jsx pragma
2013-12-28 20:05:33 -08:00
Cheng Lou
8f5ef0fdf2 docs add warning to add jsx pragma 2013-12-28 23:04:34 -05:00
Christopher Chedeau
84cacaf5b6 Merge pull request #717 from syranide/testkeytransfer
Add unit test for transferPropsTo, "key" should never transfer
2013-12-27 18:54:56 -08:00
Christopher Chedeau
72fd24662e Merge pull request #716 from bitshadow/hotfix
Issue #383 : Error message for using refs outside of render() is difficult to underst...
2013-12-27 18:53:36 -08:00
Christopher Chedeau
fdf64919f3 Merge pull request #730 from syranide/lint80
Added max line length = 80 for jshint
2013-12-27 17:59:45 -08:00
Christopher Chedeau
ff9ca2ecb2 Merge pull request #700 from syranide/100%autofocus
Patch missing autoFocus-support in older browsers
2013-12-27 17:47:24 -08:00
Christopher Chedeau
f627bc52b0 Merge pull request #714 from syranide/escapekey
Escape component keys used in reactid
2013-12-27 17:14:16 -08:00
Christopher Chedeau
9f10bb4aca Merge pull request #729 from syranide/dragevent
Add SyntheticDragEvent with "dataTransfer" property
2013-12-27 17:12:00 -08:00
Andreas Svensson
a6b888b214 Escape component keys used in reactid 2013-12-28 01:58:59 +01:00
Andreas Svensson
cbd6d8a46c Added max line length = 80 for jshint 2013-12-28 01:49:04 +01:00
Andreas Svensson
01b4b23118 Polyfill/normalize autoFocus across all browsers 2013-12-27 22:44:43 +01:00
Andreas Svensson
9e6456ba41 Add SyntheticDragEvent with "dataTransfer" property 2013-12-27 21:01:30 +01:00
Pete Hunt
a4bb44f1e2 Merge pull request #728 from spicyj/gh-724
Allow changing transitionLeave from false to true
2013-12-27 10:59:22 -08:00
Pete Hunt
fac676073a Merge pull request #722 from wincent/typo-fix-01
Fix a typo in the working-with-the-browser docs
2013-12-27 10:09:02 -08:00
Ben Alpert
5e6e332d67 Allow changing transitionLeave from false to true
Fixes #724.
2013-12-27 10:22:48 -07:00
cpojer
77697f26e3 Add invariant to check getInitialState return value. Fixes #397 2013-12-27 16:36:08 +01:00
Wincent Colaiuta
79b00591f1 Fix a typo in the working-with-the-browser docs 2013-12-26 22:22:00 -08:00
Ben Alpert
556065937b Make controlled components and bubbling work in IE
Fixes #708.

Test Plan:
In IE9, tested a controlled text input with the event handler on a containing element, as in the fiddle linked in the original issue. Also tested a controlled radio button as the logic there differs within ReactDOMInput. In both cases, I was able to interact with the controls.
2013-12-26 23:06:40 -07:00
Andreas Svensson
411f0bd7c3 Fix npm react having wrong version dependency for envify 2013-12-26 18:12:23 +01:00
Paul O’Shannessy
f877c6224f Merge pull request #695 from luigy/patch-1
Fix "Dynamic Children" example
2013-12-26 09:04:21 -08:00
Andreas Svensson
f9947dec2a Add unit test for transferPropsTo, "key" should never transfer 2013-12-26 16:42:39 +01:00
Jignesh Kakadiya
e35f4c29bb fix params 2013-12-26 12:29:01 +05:30
Jignesh Kakadiya
ecf9f8ef6d Adjust params 2013-12-26 12:17:36 +05:30
Jignesh Kakadiya
2b0dc71e3d Error message for using refs outside of render() is difficult to understand 2013-12-26 12:00:19 +05:30
Pete Hunt
cc229eb749 Merge pull request #591 from spicyj/mount-key
Respect 'key' prop for object identity
2013-12-25 22:15:13 -08:00
Ben Alpert
633125fd0d Use innerHTML not innerText in test 2013-12-25 22:47:10 -07:00
Ben Alpert
30f566392b Extract out wrapUserProvidedKey for clarity 2013-12-25 22:32:43 -07:00
Ben Alpert
6fae670d19 Make shouldUpdateReactComponent key logic clearer
...and inline getComponentKey into traverseAllChildren.js.
2013-12-25 22:25:20 -07:00
Ben Alpert
b0431a51ca Respect 'key' prop for object identity
Now when a `key` prop appears, its value is always honored. This means that in the root component or as an only child, changing key will cause remounting; in a `children` object, the `key` prop will be joined with the object key to form a two-part key.

Fixes #590.
2013-12-25 22:24:10 -07:00
Christopher Chedeau
02e47ebd00 Merge pull request #713 from syranide/nokeytransfer
transferPropsTo should never transfer the "key" property
2013-12-25 20:46:30 -08:00
Andreas Svensson
374c9ba658 transferPropsTo should never transfer the key property 2013-12-26 00:12:22 +01:00
Pete Hunt
adff7c0238 Update README.md 2013-12-24 02:21:06 -05:00
Christopher Chedeau
7e0c6bc952 Merge pull request #705 from chenglou/rm-vid
docs remove video at the bottom
2013-12-23 22:44:00 -08:00
Cheng Lou
0519734ea5 docs remove video at the bottom 2013-12-24 01:42:45 -05:00
Pete Hunt
b385b580a6 Merge pull request #704 from vjeux/talks_doc
Add a talks section to the docs
2013-12-23 22:21:56 -08:00
Vjeux
91780d1c58 Add a talks section to the docs 2013-12-24 07:20:42 +01:00
Christopher Chedeau
a6d8c00b1a Merge pull request #702 from syranide/lessmice
Removed unnecessary cleanup in isEventSupported
2013-12-23 19:30:16 -08:00
Pete Hunt
1070d12732 Merge pull request #701 from fabiomcosta/react-video-version-note
Note about react's version on the video talk
2013-12-23 16:54:33 -08:00
Pete Hunt
a8216e78b1 Merge pull request #703 from fabiomcosta/onscroll-doc-ie8-note
Adding note about onScroll on IE8
2013-12-23 16:46:52 -08:00
Fabio M. Costa
c211767d47 language update as suggested by @petehunt 2013-12-23 16:45:44 -08:00
Fabio M. Costa
34660eccf9 updating text as suggested by @petehunt 2013-12-23 16:41:41 -08:00
Fabio M. Costa
874122bad4 Adding note about onScroll on IE8 2013-12-23 16:40:41 -08:00
Andreas Svensson
63ca84e5af Removed unnecessary cleanup in isEventSupported 2013-12-24 01:02:24 +01:00
Fabio M. Costa
d22874d039 Note about react's version on the talk, since somethings have already changed since then 2013-12-23 15:37:06 -08:00
Pete Hunt
128a35dff9 Merge pull request #642 from Cartas/master
ReactTransitionGroup can handle components being re-added before 'leave' transition has completed.
2013-12-23 15:36:28 -08:00
Timothy Yung
9e0987cd9b Merge pull request #607 from syranide/html5key
Polyfill and normalize HTML5 "key", deprecates which and keyCode
2013-12-23 11:11:12 -08:00
Ben Newman
82a26ada65 Merge pull request #684 from syranide/ie8dangerousinnerhtml
Use feature detection and more robust recovering of whitespace for innerHTML in IE8.
2013-12-23 11:07:51 -08:00
Christopher Chedeau
9fa759173e Merge pull request #699 from vjeux/fix_typo
typo
2013-12-23 09:53:53 -08:00
Vjeux
a31a8c35c2 typo 2013-12-23 18:45:53 +01:00
Christopher Chedeau
47f24f26aa Merge pull request #698 from vjeux/fix_compiler
Fix html-jsx compiler
2013-12-23 09:31:19 -08:00
Vjeux
6bd9f35bf3 Fix html-jsx compiler
It changed React Playground to add a required props but unfortunately didn't update the call sites of the front-page. I don't think it should be required so I'm just making it optional and providing the correct default value.

Test Plan:
 - Open the front page and make sure examples are working
 - Open /react/jsx-compiler.html and make sure it is working
 - Open /react/html-jsx.html and make sure it is working
2013-12-23 18:24:22 +01:00
Christopher Chedeau
590a5498ab Merge pull request #686 from vjeux/community_12
Community Round-up #12
2013-12-23 09:04:03 -08:00
Vjeux
d1e955c37b Community Round-up #12 2013-12-23 18:03:42 +01:00
Paul O’Shannessy
1783e54eb0 Merge pull request #692 from loganfynne/master
Added property attribute to non-standard attributes
2013-12-22 21:30:03 -08:00
Christopher Chedeau
0bbf535b7b Merge pull request #411 from vjeux/diff_algorithm
Document the Diff algorithm
2013-12-22 11:36:26 -08:00
Andreas Svensson
1f2d57d6a4 Use feature detection and more robust recovering of whitespace for innerHTML in IE8 2013-12-22 20:30:59 +01:00
Vjeux
59f72bd991 Document the Diff algorithm
We often refer to it but never did actually explain it.
2013-12-22 20:09:02 +01:00
Ben Newman
9f3c4da588 Merge pull request #662 from benjamn/replace-envify
Upgrade envify to a version that uses recast.
2013-12-22 09:39:02 -08:00
Ben Newman
9da3f92853 Upgrade envify dependency to v1.0.1.
This version uses Recast for source transformation:
https://github.com/hughsk/envify/pull/4
2013-12-22 11:58:56 -05:00
Luigy Leon
814faed08f Fix "Dynamic Children" example 2013-12-22 10:37:09 -05:00
Pete Hunt
c7fbaa4966 Merge pull request #691 from Daniel15/hackathon40-htmltojsx-master
Simple HTML to JSX converter
2013-12-22 00:07:15 -08:00
Logan Allen
ab88dd19d3 Added property to non-standard attributes
Fixes issue #655
2013-12-21 22:24:31 -05:00
Daniel Lo Nigro
eab1f4d366 Simple HTML to JSX converter, built during Hackathon 40 at Facebook.
See /react/html-jsx.html. Not directly linked from the site yet as there may still be some minor issues with it.
2013-12-21 17:44:38 -08:00
Vjeux
c7c72d1a7a Community Round-up #14 2013-12-21 20:48:28 +01:00
Mouad Debbar
d914522ae4 A new prop type for React Components
Since we can use props to pass React Components, we should have a better way of validating these props than just `object`. Having a prop type `component` will allow us to safely assume that the passed prop IS a component.
2013-12-20 18:13:21 -08:00
Tim Yung
3431e3f847 Add createMarkupForID
This is a follow-up the to previous commit and does two things:

 - Moves `ReactMount.ATTR_NAME` to `DOMProperty.ID_ATTRIBUTE_NAME`.
 - Adds `DOMPropertyOperations.createMarkupForID` and uses it.
2013-12-20 18:12:48 -08:00
Tim Yung
9d119577ea Consolidate ID Attribute Markup Generation
We have this really nice method for safely creating markup for an HTML
attribute, `DOMPropertyOperations.createMarkupForProperty(...)`. Let's
use it to create the ID attribute markup, too.
2013-12-20 18:12:37 -08:00
Paul O’Shannessy
65e0970c41 Merge pull request #673 from quark-zju/fix-select-multiple
Some options cannot be selected alone in <select multiple />
2013-12-20 16:24:37 -08:00
Keito Uchiyama
03ab108a77 Change my canonical e-mail address in .mailmap 2013-12-20 13:59:53 -08:00
Jun, WU
3c5710193c Fix a perf issue of <select multiple />
`indexOf` was used inside a loop. Use an object and
`hasOwnProperty` instead.
2013-12-21 01:04:31 +08:00
WU Jun
9a4a8aa71a Do not automatically select other options
For <select multiple />, `value` is an array and should not be
converted to a string.
2013-12-21 01:04:31 +08:00
Cheng Lou
30672654c5 docs make all link start with /react/docs 2013-12-19 17:15:01 -05:00
Paul O’Shannessy
039124bd07 0.8 starter kit 2013-12-19 13:21:27 -08:00
Paul O’Shannessy
5c9f96d12f v0.8 blog post 2013-12-19 13:21:27 -08:00
Paul O’Shannessy
2595cbc676 Update materials for 0.8.0 2013-12-19 13:21:27 -08:00
Paul O’Shannessy
6a8542a6e9 Fix npm-react build task, add to release 2013-12-19 13:21:27 -08:00
Paul O’Shannessy
a1699bdb88 Update AUTHORS for 0.8 2013-12-19 13:21:27 -08:00
Paul O’Shannessy
a4595f0b32 Add newest starter-kit downloads to docs 2013-12-18 16:51:23 -08:00
Paul O’Shannessy
c0c5cb8e2c Changelog, blog post for 0.5.2, 0.4.2 2013-12-18 16:45:17 -08:00
Paul O’Shannessy
aabfe79442 Update readme for 0.5.2 2013-12-18 16:45:17 -08:00
Paul O’Shannessy
01c4a706a3 Add starter-kit zip files to repo
These should be included so that anybody can build and update the docs
with as little confusion as possible.

I've left the directory in .gitignore so additions need to be
intentional as part of a release.
2013-12-17 22:02:31 -08:00
Pete Hunt
9a049d9774 Merge pull request #675 from chenglou/special-attrs
docs section for non-dom attributes and more in dom differences
2013-12-17 21:51:21 -08:00
Cheng Lou
47f2cacc6b docs add input attrs for Dom Differences 2013-12-18 00:46:59 -05:00
Cheng Lou
be17771270 docs section for non-dom attributes
Also added documentation for `dangerouslySetInnerHTML`.
2013-12-18 00:31:17 -05:00
Pete Hunt
294bac537d Merge pull request #668 from nicholasbs/fix-docs-typo
Fix typos
2013-12-17 18:39:14 -08:00
Pete Hunt
b7feb6f6eb Merge pull request #650 from jaredly/patch-1
rename this tip to be less confusing
2013-12-17 18:22:34 -08:00
Pete Hunt
20d736db4c Merge pull request #674 from squidsoup/tutorial-jquery-src
Documentation (minor): template missing jquery reference
2013-12-17 18:21:53 -08:00
Kit Randel
08babd2541 Tutorial template markup needs a reference to jquery for the ajax calls
from step 13 onwards.
2013-12-18 15:13:45 +13:00
Tim Yung
41230ef5dd A new helper for tests: createHierarchyRenderer
We aren't using this in any of the React tests, but we've found it
useful testing product code.
2013-12-17 18:07:53 -08:00
Jared Forsyth
e539c8c6c4 one liner 2013-12-17 17:12:21 -07:00
Jared Forsyth
bf6951687d changes as requested 2013-12-17 17:10:02 -07:00
Jared Forsyth
b5cfc72870 adding note about initializing state w/ props 2013-12-17 16:16:50 -07:00
Ben Newman
0bf9910ae9 Merge pull request #672 from benjamn/upgrade-populist
Upgrade populist dependency to v0.1.6.
2013-12-17 13:49:51 -08:00
Ben Newman
b805eff032 Upgrade populist dependency to v0.1.6.
This reduces the time taken by `grunt populist:test` from 7s to 550ms,
which should make @spicyj especially happy.

Relevant commits from the `populist` and `ast-types` repositories:
9863ad16c0
dabef2a4ac
2013-12-17 16:26:51 -05:00
Ben Newman
df3bd393eb Merge pull request #661 from benjamn/upgrade-recast
Upgrade recast dev dependency to v0.5.6.
2013-12-17 11:54:27 -08:00
Ben Newman
f3a6775098 Upgrade recast dev dependency to v0.5.6.
Paving the way for source maps.
2013-12-17 14:50:36 -05:00
Paul O’Shannessy
c215bc3cd4 Update npm-react readme to point to autoflow 2013-12-17 11:21:08 -08:00
Paul O’Shannessy
adfb5f1eae Update npm-react error to point to autoflow 2013-12-17 11:18:27 -08:00
Pete Hunt
d663d42d23 Merge pull request #670 from subtleGradient/subtlegradient/escape-the-things
the things, escape them
2013-12-17 09:03:01 -08:00
Thomas Aylott
7f3d4f0340 fixes ReactTextComponent rootID unescapedness 2013-12-17 05:07:49 -05:00
Thomas Aylott
346c8f5e6e test case for ReactTextComponent rootID escaping 2013-12-17 05:05:28 -05:00
Nicholas Bergson-Shilcock
93eb6a5637 Fix typo in comments (ot -> to) 2013-12-15 12:12:38 -05:00
Nicholas Bergson-Shilcock
760cdd35c9 Fix typo (ot -> to) 2013-12-15 12:11:47 -05:00
Pete Hunt
3ad2938dfa Merge pull request #657 from zpao/grunt-version-check-cleanup
Grunt version check cleanup
2013-12-15 01:45:30 -08:00
Paul O’Shannessy
5a5137ded4 Merge pull request #651 from fabiomcosta/patch-2
Improving never seen error message
2013-12-13 10:23:46 -08:00
Paul O’Shannessy
c2920ba84c Merge pull request #653 from fabiomcosta/patch-3
match -> test
2013-12-12 15:33:31 -08:00
Fabio M. Costa
39037eedd1 URL -> url 2013-12-12 15:29:29 -08:00
Ben Newman
7c95194ec0 Merge pull request #637 from cpojer/use-rest-params
Use Rest Parameters where it makes sense
2013-12-12 14:53:50 -08:00
Paul O’Shannessy
8fda127748 Check src file for version-check task
This lets the task run stand-alone without building
2013-12-11 17:06:06 -08:00
Paul O’Shannessy
54bac2f07f Move version-check task into own file
Gruntfile.js is really messy :(
2013-12-11 17:01:18 -08:00
Josh Duck
8b0af9b5de Fix SelectEventPlugin
mouseup was not fired when context menu showed, so select events stopped being fired.
2013-12-11 13:46:11 -08:00
Tim Yung
02de96f012 Fix Merging propTypes, contextTypes, and childContextTypes
This fixes merging of `propTypes`, `contextTypes`, and `childContextTypes` so that we actually merge (instead of only taking the component or last mixin).
2013-12-11 13:45:55 -08:00
Ben Alpert
e92ce38cf1 Add loop property 2013-12-11 11:46:16 -08:00
cpojer
decb49a202 Use rest parameters whenever it makes sense. 2013-12-11 10:30:10 -08:00
Fabio M. Costa
c7129fd377 match -> test
Using RegExp method `test` because this is what is wanted
2013-12-11 00:43:31 -08:00
Fabio M. Costa
4b3fa413a1 Improving never seen error message
Removing repeating "support it" and fixing camelCase method name
2013-12-10 21:07:41 -08:00
Jared Forsyth
043a986ba9 fixing capitalization 2013-12-10 11:59:29 -07:00
Jared Forsyth
7640e53102 rename this tip to be less confusing
Using props to initialize state is completely fine; the issue is using state as a "cache" for values calculated based off of props. This title makes it more clear.
2013-12-10 11:50:44 -07:00
Paul O’Shannessy
b268f95e1f Merge pull request #648 from bricooke/patch-1
Update highlighted lines in tutorial
2013-12-09 23:44:51 -08:00
Paul O’Shannessy
8dfdd1d106 Make travis quieter on IRC 2013-12-09 16:03:47 -08:00
Paul O’Shannessy
80e0e2a13f Clean trailing space and lint 2013-12-09 15:54:16 -08:00
Paul O’Shannessy
5c65abfbac Merge remote-tracking branch 'syranide/textarearows' 2013-12-09 15:51:38 -08:00
Paul O’Shannessy
904cf15972 Merge pull request #646 from spicyj/lint2
Fix lint error (unused variable)
2013-12-09 15:49:02 -08:00
Brian Cooke
42dee34146 Update highlighted lines in tutorial
Minor issue, but I found it distracting that the highlighted lines were not accurate. I *believe* this fixes them up.
2013-12-09 15:16:37 -08:00
Ben Alpert
277abbfe7b Fix lint error (unused variable) 2013-12-09 12:29:03 -08:00
Thomas Aylott
00c8160f8e Merge pull request #628 from subtleGradient/subtlegradient/travis-task-cleanup
add browser testing to travis
2013-12-09 12:19:33 -08:00
Thomas Aylott
feeebfbc51 removed complexity report until it's fixed 2013-12-09 14:55:21 -05:00
Thomas Aylott
55f50ca4d1 enable code coverage and code complexity reports 2013-12-09 14:55:21 -05:00
Thomas Aylott
0c366ce648 fix lint 2013-12-09 14:55:21 -05:00
Thomas Aylott
1b477fa40c move sauce labs config out of the Gruntfile 2013-12-09 14:55:21 -05:00
Thomas Aylott
a41c20d43b sets each IE separately for now 2013-12-09 14:55:20 -05:00
Thomas Aylott
fe8008e67c PICK ALL THE NITS!!!1! 2013-12-09 14:55:20 -05:00
Thomas Aylott
4af362b751 combine iOS and IE matrix tests 2013-12-09 14:55:20 -05:00
Thomas Aylott
8e3cb7bd9d tests fail in Safai now. unblocking for now.
Add these back in as build blockers once those issues are fixed.
2013-12-09 14:55:20 -05:00
Thomas Aylott
c6f99c3a84 iOS is failing again. Will debug separately 2013-12-09 14:55:20 -05:00
Thomas Aylott
b8ee94d999 define public saucelabs info for everything to use 2013-12-09 14:55:20 -05:00
Thomas Aylott
3308137d8d run tests in old iOS, but allow failures 2013-12-09 14:55:20 -05:00
Thomas Aylott
e944b68e8c new grunt test:full task tests in many browsers
Moved the travis specific stuff back into the travis file
2013-12-09 14:55:20 -05:00
Thomas Aylott
e560229c83 secure tokens aren't available for pull requests
Now you can use the saucelabs jazz locally also.
2013-12-09 14:55:20 -05:00
Thomas Aylott
18459deb77 enable IE browser testing in travis 2013-12-09 14:55:20 -05:00
Thomas Aylott
a13bd1e251 simplify travis script 2013-12-09 14:55:20 -05:00
Ben Alpert
7325189890 Fix scrollLeft/scrollTop warning in latest Chrome
Chrome gives the warnings

```
body.scrollLeft is deprecated in strict mode. Please use 'documentElement.scrollLeft' if in strict mode and 'body.scrollLeft' only if in quirks mode.
body.scrollTop is deprecated in strict mode. Please use 'documentElement.scrollTop' if in strict mode and 'body.scrollTop' only if in quirks mode.
```

the first time getUnboundedScrollPosition is invoked. This fixes it. (All modern browsers support `pageYOffset`; IE 8 doesn't but works properly with `document.documentElement.scrollTop` except in quirks mode which React doesn't support.)
2013-12-07 15:57:23 -08:00
Paul O’Shannessy
153b75f186 Bump version to 0.9.0-alpha
This is trunk, which will be 0.9. We'll have to cherry-pick this whole
thing into a 0.8 branch.
2013-12-06 15:11:25 -08:00
Paul O’Shannessy
a42b61fa85 Fix botched rebase 2013-12-06 15:10:57 -08:00
Paul O’Shannessy
ce0f244c54 Move npm-react-core to npm-react, fix tasks accordingly 2013-12-06 15:10:15 -08:00
Paul O’Shannessy
9fdf589976 Update react package readme 2013-12-06 12:03:16 -08:00
petehunt
ef339c9cc4 Version bump, make tests work 2013-12-06 11:56:30 -08:00
petehunt
e5c4a3c7d5 update README 2013-12-06 11:56:30 -08:00
petehunt
036e621467 version bump to 0.8 to get on top of react.js 2013-12-06 11:56:30 -08:00
petehunt
0b97c6438e rename to with associated warnings 2013-12-06 11:56:30 -08:00
petehunt
6269cbf482 rename to with associated warnings 2013-12-06 11:56:30 -08:00
petehunt
82f211f6b8 revert muffinize :( 2013-12-06 11:56:30 -08:00
petehunt
90e2258791 response to code review 2013-12-06 11:56:30 -08:00
petehunt
d197992dc8 update npm-react-core package.json 2013-12-06 11:56:30 -08:00
Paul O’Shannessy
9162cb8abe react-core npm module 2013-12-06 11:56:29 -08:00
petehunt
e839405202 muffinification 2013-12-06 11:56:29 -08:00
petehunt
5466d0a063 first work: __DEV__
fix invariant

Get browserify working

remove dead code elimination step since it is not needed due to minifier

use industry standard NODE_ENV
2013-12-06 11:56:29 -08:00
Paul O’Shannessy
9270d3d56e Merge pull request #592 from spicyj/guard-fn
ReactErrorUtils: In prod, just return the original
2013-12-06 11:31:02 -08:00
Cartas
7d8190f56e Updated the animation-fix to account for transitionEnter being false. 2013-12-06 15:37:38 +01:00
Cartas
c313a1045d Nodes that have had their child removed already, but then get given a new one no longer bug-out.
In the case of having an animated node which is, after the leave-transition has been activated, then re-added in a render call causes React to 'break'.  This is especially noticeable if you spam to removal and re-addition of an item in a ReactTransitionGroup.

This fix simply stops the leave transition and restarts the enter transition.
2013-12-06 14:46:33 +01:00
Ben Alpert
1be9a9e986 Bump version of wd
wd 0.2.2 gives `TypeError: Cannot call method 'jsCondition' of undefined` since #551; 0.2.6 is the latest and works so switch to that.
2013-12-05 17:13:52 -08:00
Paul Shen
12e765dd27 Revert "Don't mutate passed-in props"
This reverts https://github.com/facebook/react/pull/576

This approach mutates the default props for the instance on each update,
which causes incorrect behavior. discussed with @balpert. can look into
cloning but this unbreaks.
2013-12-05 16:53:43 -08:00
Paul O’Shannessy
a7f6082c9c Merge pull request #636 from cpojer/rest-parameters-react
Add more useful ES6 transforms to jsx-internal.
2013-12-05 16:47:31 -08:00
Paul O’Shannessy
2ebbbc5145 Followup fix for lint 2013-12-05 15:55:49 -08:00
Paul O’Shannessy
7db8f818bc Merge remote-tracking branch 'spicyj/depth-not-owner' 2013-12-05 15:51:39 -08:00
Thomas Aylott
55e3b64ff4 Merge pull request #635 from subtleGradient/subtlegradient/fixes-webdriver-test
fixes webdriver issues
2013-12-05 14:55:52 -08:00
Thomas Aylott
d035268c41 Merge pull request #617 from subtleGradient/subtlegradient/complexity-task
NEW `grunt complexity` reporting task
2013-12-05 14:55:17 -08:00
Ben Alpert
d0883c8cc7 Use depth (not owner) to check for root components
Fixes #557.
2013-12-05 13:36:29 -08:00
Thomas Aylott
2807202ee7 bump webdriver timeouts
fixes #634
fixes #551
2013-12-05 16:27:26 -05:00
Thomas Aylott
60f2e45d2d fixes test runner for IE8 2013-12-05 16:27:26 -05:00
Thomas Aylott
c222c46146 filter out tests from complexity report 2013-12-05 16:27:10 -05:00
Thomas Aylott
2b3e97b5a4 NEW grunt complexity reporting task 2013-12-05 16:27:10 -05:00
Andreas Svensson
27b8e7a6f4 corrections 2013-12-05 19:40:48 +01:00
cpojer
31359e9962 Add more useful ES6 transforms to jsx-internal. 2013-12-05 10:20:24 -08:00
Andreas Svensson
4d6d4b54d6 Fix ReactDOMTextarea missing "rows" and "cols" attribute, incorrect "size" property 2013-12-05 18:36:48 +01:00
Andreas Svensson
e060eabb01 Add HAS_POSITIVE_NUMERIC_VALUE to DOMProperty and normalize behavior of null values
Uniformly remove null values, rather than sometimes set/remove, could potentially assign 'null' or 'undefined'
2013-12-05 18:36:46 +01:00
Paul O’Shannessy
09bdcefd4f Notify travis build results in IRC channel
If this gets noisy, we can change to only notify on change.
2013-12-04 21:19:24 -08:00
Paul O’Shannessy
2bbc42ce41 Update package devDependencies 2013-12-04 21:07:16 -08:00
Marshall Roch
d17bd176a2 Remove support for putting mixins, propTypes, etc. in 'statics'
This leaves statics as a way to define static methods and properties
that will be accessible on the return value of `React.createClass`
without changing the current spec.
2013-12-04 20:27:44 -08:00
Sean Kinsey
c2e48740fc [ReactTransitionGroup] Add onTransitionEnter and onTransitionLeave
It is valuable to know when the number of children in a TransitionGroup is going
to increase or decrease, since we might want to apply extra animations.
For instance, when used with overflow:auto, we might want to apply different css
based on it overflowing or not - to do this we need to calculate this after new
nodes has entered and after nodes has been removed.
2013-12-04 20:27:28 -08:00
John Watson
bf24dc33f7 Separate replaceState invariant violations
It'd be nice if we knew which error we were hitting when this invariant hit.
2013-12-04 20:27:24 -08:00
Marshall Roch
e3ad088ff3 Remove deprecation warning for React statics 2013-12-04 20:27:19 -08:00
Paul O'Shannessy
1b8bdbe177 Remove deprecated React.unmountAndReleaseReactRootNode 2013-12-04 20:27:15 -08:00
Marshall Roch
79b9d5af62 Introduce 'statics' for class specification
This moves the static properties off of the root object and into
a 'statics' property. Then they are made available on the constructor so
they can be used directly and in mixins.
2013-12-04 18:39:44 -08:00
Ben Newman
66f6cbad56 Merge pull request #535 from benjamn/commoner-cache-buster
Establish a convention for forcing jsx rebuilds.
2013-12-04 13:54:29 -08:00
Ben Newman
057c88ce52 s/jsxConfig/commonerConfig/g 2013-12-04 16:47:13 -05:00
Ben Newman
3527d9d91c Establish a convention for forcing jsx rebuilds.
Pull request #526 updated the behavior of vendor/constants.js without
changing any source files or the bin/jsx-internal script, so files that
should have been rebuilt (like utils/__tests__/ImmutableObject-test.js)
were not automatically rebuilt (unless you knew to do `grunt clean` or
`rm -rf .module-cache` manually).

This commit allows us to bump a version number when we know the transform
toolchain has been altered in a way that will not be visible to
commoner/jsx.

With this convention, if we reset to an older revision (e.g. during a git
bisect) and the appropriate cached module files are still in the
.module-cache/, they can be used without rebuilding. That's why I prefer
this approach to just deleting the .module-cache/.

Closes #104.
Closes #496.
Closes #530.
2013-12-04 16:36:59 -05:00
Ben Newman
affe7f98b5 Merge pull request #367 from benjamn/findComponentRoot-memory-usage-improvements
Space optimizations for ReactMount.findComponentRoot.
2013-12-04 13:20:29 -08:00
Paul O’Shannessy
bcd7b5d194 Merge pull request #630 from spicyj/remove-updatePropertiesByID
Remove unused updatePropertiesByID
2013-12-04 10:34:35 -08:00
Ben Alpert
9d443542f9 Remove unused updatePropertiesByID 2013-12-03 19:22:36 -08:00
Ben Newman
87db648f3e Address pull request feedback. 2013-12-03 16:43:37 -05:00
Ben Newman
6b9fc81b64 Space optimizations for ReactMount.findComponentRoot. 2013-12-03 16:43:37 -05:00
Vjeux
e4909d0f2e Add video at the bottom of the front page 2013-12-03 12:11:12 -08:00
Paul O’Shannessy
9d18956b09 Merge pull request #624 from spicyj/remove-registrationNamesKeys
Remove unused event plugin registrationNamesKeys
2013-12-02 16:03:36 -08:00
Paul O’Shannessy
cd3bfe64d4 Fix blog pagination
I missed this in the Jekyll upgrade.
2013-12-02 15:46:20 -08:00
Paul O’Shannessy
241f4d29b2 [docs] Fix download links to addons builds 2013-12-02 15:13:49 -08:00
Pete Hunt
3851462b80 Fix lint warnings 2013-12-02 13:32:09 -08:00
Paul O’Shannessy
76e3294c8f Merge pull request #609 from subtleGradient/subtlegradient/fixes-ios-crasher
fixes iOS crasher
2013-12-02 13:25:40 -08:00
Paul O’Shannessy
d64256fb65 Merge pull request #626 from spicyj/getUnboundedScrollPosition-license
Add missing license header
2013-12-02 09:07:07 -08:00
petehunt
00adabc20d Fix frontpage example to retain selection 2013-12-02 04:04:45 -08:00
Ben Alpert
1cb402c410 Add missing license header 2013-12-02 01:12:20 -08:00
Pete Hunt
e923e22c16 Merge pull request #625 from spicyj/patch-3
Tweaks to README
2013-12-01 23:06:51 -08:00
Ben Alpert
55cd8bee35 Tweaks to README
Most significant change is updating the leading copy to match #440.
2013-12-01 22:49:46 -08:00
Ben Alpert
4323ab095f Remove unused event plugin registrationNamesKeys 2013-12-01 22:28:19 -08:00
Pete Hunt
22dc8fa765 Merge pull request #602 from chenglou/tips-bind
docs tips pass arguments to callbacks
2013-12-01 19:07:14 -08:00
Cheng Lou
e98244adb5 docs tips parent-child communication 2013-12-01 21:39:22 -05:00
Pete Hunt
92b62bf1fe Merge pull request #576 from spicyj/immutable-props
Don't mutate passed-in props
2013-12-01 18:26:41 -08:00
Pete Hunt
2a84b6c6b2 Merge pull request #537 from hojberg/dont_animate_undefined_children
ReactTransitions: Don't animate undefined children
2013-12-01 14:21:11 -08:00
Pete Hunt
285e3a8929 Merge pull request #440 from petehunt/new-taglines
New marketing copy
2013-12-01 14:00:13 -08:00
Pete Hunt
ab36b114fc Merge pull request #581 from chenglou/docs-select-value
docs `select` `value` to control chosen option
2013-12-01 13:53:12 -08:00
Paul O’Shannessy
d8a1dbb19c Merge pull request #618 from chenglou/didmout-didUpdate-new
docs remove rootNode for componentDidMount/Update
2013-11-27 18:50:10 -08:00
Cheng Lou
cffb115480 docs remove rootNode for componentDidMount/Update 2013-11-27 21:46:02 -05:00
Paul O’Shannessy
98b9e2faeb Merge pull request #599 from chenglou/dl-addons
docs add download links for react-with-addons
2013-11-27 14:48:42 -08:00
Cheng Lou
11638b7824 docs add download links for react-with-addons 2013-11-27 17:31:27 -05:00
Paul O’Shannessy
8fbdb50a9d Merge pull request #597 from spicyj/gh-527
Don't use .returnValue if .defaultPrevented exists
2013-11-27 14:28:26 -08:00
Paul O’Shannessy
5fbd8109f8 Merge pull request #598 from spicyj/gh-516
Be resilient to fn.name not existing in IE
2013-11-27 14:28:02 -08:00
Paul O’Shannessy
126ef094fc Merge pull request #593 from spicyj/run-lint
Run lint on Travis in a matrix
2013-11-27 14:14:33 -08:00
Thomas Aylott
916ee6b394 jsx & JSDOM support 2013-11-27 17:04:40 -05:00
Ben Alpert
2104327ba1 Run lint automatically on Travis (in a matrix) 2013-11-27 16:53:57 -05:00
Paul O’Shannessy
42eef0e9d6 Merge pull request #610 from chenglou/jsx-js
make docs jsx compiler highlight transpiled js code
2013-11-27 12:22:51 -08:00
Paul O’Shannessy
e31fdfd0b3 Merge pull request #616 from davidhellsing/patch-1
Backbone example: changed key from Math.random() to todo.cid
2013-11-27 12:14:40 -08:00
Marshall Roch
697a9113c0 ReactPropTypes: add oneOfType to support union types
Summary:
e.g.

  propTypes: {
    foo: React.PropTypes.oneOfType([
      React.PropTypes.string,
      React.PropTypes.number
    ]);
  }

to do this, I exposed a `.weak` chainable validator that returns instead of throws, e.g.

  React.PropTypes.string.isRequired.weak
  React.PropTypes.string.weak

which returns true or false. Technically, `React.PropTypes.string.weak.isRequired` also exists, but `oneOfType` will never call it. Might be useful to people creating custom validators though.
2013-11-27 12:10:50 -08:00
Marshall Roch
351dcfed01 Validate propTypes, contextTypes, childContextTypes
who watches the watchmen?
2013-11-27 12:10:50 -08:00
Pete Hunt
fcfe516a2e Less verbose ReactPropTypeLocations logging
Since we use keyMirror() and invariant() messages are only shown in __DEV__, we don't have to do manual constant->string translation. Also fixes a few
undefined keys that just happened to work before.
2013-11-27 12:10:50 -08:00
Paul O’Shannessy
9886e40395 Merge pull request #594 from spicyj/skip-spec
Allow running one spec/suite in the web interface
2013-11-27 11:54:31 -08:00
Paul O’Shannessy
a7811fb75b Merge pull request #595 from spicyj/old-logger
Remove reference to old browser logger
2013-11-27 11:46:15 -08:00
David Hellsing
a79ef7fc29 Changed key from Math.random() to todo.cid
It doesn’t make much sense to generate a random key for each todo render, because it will re-draw all todo’s DOM nodes on each model change. I changed it to the unique identifier ``todo.cid`` already supplied by the backbone model.
2013-11-26 18:07:56 +01:00
Andreas Svensson
15ce8ecfe9 Polyfill and normalize HTML5 "key", deprecates which and keyCode 2013-11-26 10:09:50 +01:00
Cheng Lou
92ea31c7b7 make docs jsx compiler highlight transpiled js code 2013-11-25 19:04:28 -05:00
Thomas Aylott
f4753030a2 IE support 2013-11-25 16:02:01 -05:00
Thomas Aylott
3bfb687de3 remove warning comment about createHTMLDocument 2013-11-25 15:08:00 -05:00
Thomas Aylott
eebad16636 Use an iframe to create a testDocument…
instead of `createHTMLDocument` since it isn't fully support by the browsers we care about.

fixes #606
fixes #454
2013-11-25 15:05:35 -05:00
Thomas Aylott
564c8669f8 Merge pull request #596 from spicyj/gh-532
'getElementsByClassName' doesn't exist in IE8
2013-11-25 09:29:52 -08:00
Pete Hunt
a7f0afceec Merge pull request #589 from balanceiskey/master
Minor spelling correction in docs
2013-11-24 20:53:35 -08:00
Ben Newman
1f8f0ae2d6 Merge pull request #601 from spicyj/commoner-088
Update commoner to 0.8.8 for Windows support.
2013-11-24 13:06:59 -08:00
Ben Alpert
0e2840abce Update commoner to 0.8.8 for Windows support
benjamn/commoner#44 fixed commoner to work on Windows when module path relativization isn't used; with this, the `jsx` binary should work properly on Windows (though `jsx-internal` still won't).

Fixes #316, fixes #391, fixes #567.
2013-11-24 16:02:01 -05:00
Ben Alpert
685dec022a Be resilient to fn.name not existing in IE
Fixes #516.
2013-11-24 01:53:53 -05:00
Ben Alpert
e6e71a4953 ReactErrorUtils: In prod, just return the original
This will save a stack frame (nice when in a debugger) and presumably be a bit faster.
2013-11-24 01:47:15 -05:00
Ben Alpert
4bd0a40037 Don't use .returnValue if .defaultPrevented exists
`.defaultPrevented` exists in IE9+. I checked in IE9, Chrome, and Firefox that it does default to `false`.

Fixes #527.
2013-11-24 01:35:49 -05:00
Ben Alpert
b99fd93684 'getElementsByClassName' doesn't exist in IE8
Fixes #532.
2013-11-24 01:22:00 -05:00
Ben Alpert
67c851792a Remove reference to old browser logger
The file was removed in 37bb9b76aba0deb445874273b93955ffb1c18bf8; this was giving a 404.
2013-11-24 01:04:09 -05:00
Ben Alpert
3a75d70501 Allow running one spec/suite in the web interface
This is the proper way to make it filter the spec list:

https://github.com/pivotal/jasmine/blob/1_3_x/spec/runner.html

I submitted the jasmine-jsreporter change as a pull request here:

https://github.com/detro/jasmine-jsreporter/pull/2

Fixes #563.
2013-11-24 00:53:29 -05:00
Sundeep Malladi
b7ef221b27 Minor spelling correction in docs 2013-11-22 14:32:53 -06:00
Pete Hunt
d51ae6b8bc Merge pull request #575 from spicyj/owner
Move __owner__ off of props
2013-11-21 17:44:48 -08:00
Ben Alpert
61abc645e5 Move __owner__ off of props 2013-11-21 17:34:52 -08:00
Ben Newman
2a66c9b089 Merge pull request #586 from benjamn/reinstate-ReactEventEmitter-mocking
Add back mocking removed to make ReactEventTopLevelCallback-test pass.
2013-11-21 11:07:57 -08:00
Ben Newman
52d3b47f48 Add back mocking removed to make ReactEventTopLevelCallback-test pass.
This is a partial reversion of commit 9937f0c8bd.
2013-11-21 10:57:24 -08:00
Ben Newman
97bbd852b2 Merge pull request #584 from spicyj/mock
Mock modules properly in test runner.
2013-11-21 10:31:59 -08:00
Ben Alpert
af95b35f27 Have faith in var hoisting 2013-11-21 10:31:20 -08:00
Ben Alpert
c7bb3af760 Mock modules properly in test runner
As an added bonus, the jasmine web interface now groups tests by file.

Test Plan:
grunt test passes on b2507066, the parent of 566f8b2e (which committed a workaround for buggy module mocking).
2013-11-21 00:39:37 -08:00
Cheng Lou
0a3d0163d0 docs select value to control chosen option 2013-11-20 22:34:53 -05:00
Ben Newman
566f8b2e85 Merge pull request #573 from spicyj/tests
Make ReactEventTopLevelCallback-test pass
2013-11-20 16:54:15 -08:00
Paul O’Shannessy
b2507066b6 Don't call utils.traverse in transform
Accidental change we missed in review of #495.
2013-11-20 15:36:54 -08:00
Christopher Chedeau
e73900dad4 Remove rootNode from componentDidMount and componentDidUpdate
We can already access the DOM node using `this.getDOMNode()`. Passing it as an argument was a bad decision.

Previous API:

```
componentDidMount(DOMElement rootNode)
componentDidUpdate(object prevProps, object prevState, object prevContext, DOMElement rootNode)
```

Next API:

```
componentDidMount()
componentDidUpdate(object prevProps, object prevState, object prevContext)
```
2013-11-20 14:20:35 -08:00
Christoph Pojer
2fe2cd5337 Ensure ReactPerf always uses a string as a URL 2013-11-20 14:19:13 -08:00
Tim Yung
04c3e2e407 Add nextContext to componentWillReceiveProps
Add `nextContext` as an argument to `componentWillReceiveProps`. We can figure out what to rename the method to later.
2013-11-20 14:19:01 -08:00
Christopher Chedeau
a23d43bf05 Use this.getDOMNode() instead of last argument of componentDidMount 2013-11-20 14:18:49 -08:00
Marshall Roch
934ef1d4c2 Fix context in callbacks
callbacks like shouldComponentUpdate, componentDidUpdate, etc. were getting the full, unsanitized context, instead of the one that's been filtered down to only the fields allowed to be visible by contextTypes.
2013-11-20 14:18:28 -08:00
Christopher Chedeau
c8b6fe51d9 Use this.getDOMNode() instead of last argument of componentDidUpdate
Context is adding another argument that shifts all of them by one. Since we can already use this.getDOMNode(), it doesn't really make sense to pass it as an argument to that function.
2013-11-20 14:18:07 -08:00
Marshall Roch
3fd3341ab9 remove transaction argument from componentWillReceiveProps 2013-11-20 14:17:23 -08:00
Paul O'Shannessy
060118c7e4 order object properties consistently 2013-11-20 14:17:13 -08:00
Pete Hunt
3651b8892f Merge pull request #578 from spicyj/patch-2
autoBind -> Autobinding
2013-11-20 11:47:22 -08:00
Ben Alpert
d49d84b250 autoBind -> Autobinding
We don't use the term autoBind anywhere any more.
2013-11-20 11:42:05 -08:00
Pete Hunt
0df4be849f Merge pull request #577 from stillmotion/master
Add explination of autoBind to DOM Event Listener tip
2013-11-20 11:41:11 -08:00
Levi McCallum
ceaf3fba32 Add explination of autoBind to DOM Event Listener tip 2013-11-20 11:29:05 -08:00
Ben Alpert
42c14b8078 Don't mutate passed-in props
Depends on #575; fixes #570.  Now we'll be in trouble if someone tries to share objects between calls to getDefaultProps but that was already true of getInitialState and I haven't heard any complaints there.

This is the same number of allocations as before; we're just copying props in the other direction. (In any case, the copy happens only on mount and there are a couple dozen costlier things we're doing already at that time.)
2013-11-20 01:17:10 -08:00
Ben Alpert
9937f0c8bd Make ReactEventTopLevelCallback-test pass
This module-level mock() seems to have been interfering with other tests (26 specs failing). We don't have any other tests that do a module-level mock() so I'm going to assume it isn't supported in the open-source test runner right now. I changed it so only ReactEventEmitter.handleTopLevel is mocked; doing so made ReactEventEmitter complain that TopLevelCallbackCreator wasn't defined so I switched the ReactMount references to use React directly so that ReactDefaultInjection would kick in properly.

With this, all the tests pass.
2013-11-19 23:46:32 -08:00
Paul O’Shannessy
bd1f5e7e16 Put nav data in "_data"
New in Jekyll 1.3 - http://jekyllrb.com/docs/datafiles/
2013-11-19 15:52:42 -08:00
Paul O’Shannessy
f37fd7a7a3 Fix pagination 2013-11-19 15:25:00 -08:00
Paul O’Shannessy
378a49bf3c Update jekyll to 1.3 2013-11-19 15:18:15 -08:00
Vjeux
96e97c1a87 Community round-up #11 2013-11-19 22:56:34 +01:00
Paul O’Shannessy
5f22259964 Merge pull request #565 from chenglou/className-htmlFor
docs highlight className and htmlFor transforms
2013-11-19 11:01:10 -08:00
Jeff Morrison
ab47e99215 Merge pull request #495 from syranide/fixutils
utils.* is now used everywhere
2013-11-19 10:59:16 -08:00
Cheng Lou
1fcd6412fb docs highlight className and htmlFor transforms 2013-11-18 21:42:51 -05:00
Cheng Lou
ce0eec97db docs classSet semicolons missing 2013-11-18 21:22:14 -05:00
Paul O’Shannessy
5d2f0b4e07 Merge branch 'chenglou-classSet'
closes #463
2013-11-18 18:00:24 -08:00
Paul O’Shannessy
e79079d174 Merge pull request #539 from spicyj/doc-anchors-again
Make doc headers clickable again
2013-11-18 17:45:39 -08:00
Ben Alpert
e94ebee15e Make doc headers clickable again
...without preventing clicks on other things.

Just use an `<a name="...">` tag that doesn't take up any space to make sure that we're not covering up something else.

For whatever reason, doing `position: relative; top: -$navHeight;` doesn't work and causes the anchor target not to be moved up. This solution works in both Chrome and Firefox.
2013-11-18 17:34:44 -08:00
Ben Newman
5d878ce914 Merge pull request #550 from subtleGradient/subtlegradient/code-coverage
Code coverage grunt tasks.
2013-11-18 14:03:56 -08:00
Thomas Aylott
5ae152cdcf simplified the sort function 2013-11-18 16:37:47 -05:00
Thomas Aylott
c6f7fe00fa Lines too long; reformatted 2013-11-18 16:37:47 -05:00
Thomas Aylott
45063aed44 picked all the lint 2013-11-18 16:37:47 -05:00
Thomas Aylott
5feb745b02 fixes the case when coverage isn't turned on 2013-11-18 16:37:47 -05:00
Thomas Aylott
eda56b7af2 new grunt test:coverage task 2013-11-18 16:37:47 -05:00
Thomas Aylott
8f96ec255b new grunt browserify:withCodeCoverageLogging task 2013-11-18 16:37:47 -05:00
Thomas Aylott
ad0d9e4761 consoleLoggerMiddleware handles coverage logs 2013-11-18 16:37:47 -05:00
Thomas Aylott
b5b60a6acf speed up server middleware slightly 2013-11-18 16:37:46 -05:00
Thomas Aylott
cb6b7f37e7 fixes an issue where the list of files to test isn't complete 2013-11-18 16:37:46 -05:00
Thomas Aylott
ef5a02c164 enable coverage logging from the worker 2013-11-18 16:37:46 -05:00
Thomas Aylott
646421f71f batch logs until the end unless ran with --debug 2013-11-18 16:37:46 -05:00
Thomas Aylott
4c881d8487 require coverify 2013-11-18 16:37:46 -05:00
Thomas Aylott
5aa901336c ignore logs and testing stuff 2013-11-18 16:37:46 -05:00
Thomas Aylott
61c1bf0a41 fixes browserify task transforms support 2013-11-18 16:37:46 -05:00
Daniel Lo Nigro
d853c8568e Propagate events to parent components when nested
When events are captured, the nearest React-rendered ancestor is found and events are propagated to its tree. This causes issues when components are nested as only the innermost component receives the events.

This change modifies this behaviour so events propagate all the way up the DOM hierarchy. To reduce the performance cost, this DOM traversal is only done if the component is actually nested (determined by the `containerIsNested` map which is lazily initialised).
2013-11-18 10:56:29 -08:00
Marshall Roch
b91396be8e Contexts
Summary:
adds `this.context` which you can think of as implicit props, which are passed automatically down the //ownership// hierarchy.

Contexts should be used sparingly, since they essentially allow components to communicate with descendants (in the ownership sense, not parenthood sense), which is not usually a good idea. You probably would only use contexts in places where you'd normally use a global, but contexts allow you to override them for certain view subtrees which you can't do with globals.

The context starts out `null`:

  var RootComponent = React.createClass({
    render: function() {
      // this.context === null
    }
  });

You should **never** mutate the context directly, just like props and state.

You can change the context of your children (the ones you own, not `this.props.children` or via other props) using the new `withContext` method on `React`:

  var RootComponent = React.createClass({
    render: function() {
      // this.context === null
      var children = React.withContext({foo: 'a', bar: 'b'}, () => (
        // In ChildComponent#render, this.context === {foo: 'a', bar: 'b'}
        <ChildComponent />
      ));
      // this.context === null
    }
  });

Contexts are merged, so a component can override its owner's context **for its children**:

  var ChildComponent = React.createClass({
    render: function() {
      // this.context === {foo: 'a', bar: 'b'} (for the caller above)
      var children = React.withContext({foo: 'c'},() => (
        // In GrandchildComponent#render,
        // this.context === {foo: 'c', bar: 'b'}
        <GrandchildComponent />
      ));
      // this.context === {foo: 'a', bar: 'b'}
    }
  });
2013-11-18 10:56:24 -08:00
Pete Hunt
7df127db31 Better error message for renderComponentToString()
Reported on Twitter by AirBnb (who are integrating React into their open-source JS framework). They made a mistake and passed a string in as the
component. We should have a better error message for that.
2013-11-18 10:54:05 -08:00
Tim Yung
8529f1b053 Remove Obsolete IE8 Compatibility Code
See the TODO comment. Synthetic events have shipped and this is no longer necessary.
2013-11-18 10:54:03 -08:00
Marshall Roch
381a3392c6 Rename receiveProps to receiveComponent
This renames receiveProps and changes it to take the next component to copy props from instead of just the props. That is,

  component.receiveComponent(nextComponent, transaction)

instead of

  component.receiveProps(nextComponent.props, transaction)

This is a precursor to adding contexts, which will also need to get propagated just like props. This change allows ReactCompositeComponent to override `receiveProps` and do something like

  this._pendingContext = nextComponent.context;
2013-11-18 10:53:58 -08:00
Andreas Svensson
a39b8fda70 utils.* is now used everywhere 2013-11-15 11:17:24 +01:00
Pieter Vanderwerff
1e1d7fe770 Set docs menu item to active when viewing a “tips” page 2013-11-15 15:27:31 +13:00
Paul O’Shannessy
e6010bf75e Merge pull request #362 from mcsheffrey/feat-documentation-cookbook
React Tips documentation
2013-11-14 14:59:41 -08:00
Paul O’Shannessy
d1fa53ca03 Cleanup lint warnings from recent testing changes
Also, relaxed a rule for dot notation (and unrelaxed it in src).
2013-11-14 11:24:06 -08:00
Connor McSheffrey
26c142df82 Merge pull request #20 from zpao/tips
Updates to tips
2013-11-14 11:17:34 -08:00
Ben Newman
b61eacd3c5 Explicitly require the assert module in vendor/constants.js. 2013-11-14 13:48:08 -05:00
Paul O’Shannessy
1324eb5556 "use strict" in shouldUpdateReactComponent 2013-11-14 10:37:33 -08:00
Paul O’Shannessy
9cb3a3a182 Remove modules cache with grunt clean 2013-11-14 10:37:07 -08:00
Ben Newman
f9423241d9 Merge pull request #510 from subtleGradient/subtlegradient/run-the-browser-tests-on-saucelabs
Make it easy to run the browser tests on saucelabs.
2013-11-14 10:08:51 -08:00
Simon Højberg
5b1e4c0324 Transitions: Handle undefined input to mergeKeySet
Gracefully handle undefined input to mergeKeySet.
2013-11-13 23:02:06 -05:00
Simon Højberg
acbddd2641 ReactTransitions: Don't animate undefined children 2013-11-13 20:54:22 -05:00
Paul O’Shannessy
c821887160 formatting and syntax on false in JSX tip 2013-11-13 17:43:17 -08:00
Paul O’Shannessy
4367dad669 Update wording on AJAX tip 2013-11-13 17:43:17 -08:00
Paul O’Shannessy
0ebd3d92ba Fix broken link, spacing on events tip 2013-11-13 17:43:17 -08:00
Paul O’Shannessy
80ab7bf4e1 s/Zuck/Rogers/ 2013-11-13 17:43:17 -08:00
Paul O’Shannessy
4a9ed4a204 Fix broken link on componentWillReceiveProps tip 2013-11-13 17:43:16 -08:00
Paul O’Shannessy
f6f3d4262b fix broken link on controlled input tip 2013-11-13 17:43:16 -08:00
Paul O’Shannessy
75383c5c99 Children props tip tweak 2013-11-13 17:43:16 -08:00
Paul O’Shannessy
49261c9392 Fix broken link, formatting on px style tip 2013-11-13 17:43:16 -08:00
Paul O’Shannessy
fe52e059b9 Tweak for self closing tag tip 2013-11-13 17:43:16 -08:00
Paul O’Shannessy
684e5922e8 Tweaks to if-else tip 2013-11-13 17:43:16 -08:00
Paul O’Shannessy
7c1cf0a2dc Small cleanup to style tips 2013-11-13 17:43:16 -08:00
Pete Hunt
dab167c0e3 Merge pull request #460 from chenglou/opacity-1
fix doc & example transition opacity from .99 to 1
2013-11-13 17:31:08 -08:00
Thomas Aylott
326e3a33ac Merge pull request #529 from benjamn/upgrade-populist
Upgrade populist version to v0.1.5 for better error reporting
2013-11-13 14:50:36 -08:00
Ben Newman
d44c07b9a7 Upgrade populist version to v0.1.5 for better error reporting. 2013-11-13 17:42:17 -05:00
Thomas Aylott
22829b5529 remove unnecessary task config 2013-11-13 16:49:08 -05:00
Thomas Aylott
c4cd02efc5 fixes #513 2013-11-13 16:22:11 -05:00
Thomas Aylott
d1fd4058da sauce labs browser configs for running manually 2013-11-13 16:22:11 -05:00
Thomas Aylott
08bd1f98e5 wait a little longer for the page to load 2013-11-13 16:22:11 -05:00
Thomas Aylott
2d6eb3d8fc don't log your password to the console 2013-11-13 16:22:11 -05:00
Thomas Aylott
4daeda1490 log individual test results when in --debug mode 2013-11-13 16:22:11 -05:00
Thomas Aylott
c1925db067 cleanup 2013-11-13 16:22:11 -05:00
Thomas Aylott
cd24cbdbf4 name local saucelabs tests too 2013-11-13 16:22:11 -05:00
Thomas Aylott
d9b7e47824 sped up the webdriver tests 2013-11-13 16:22:11 -05:00
Thomas Aylott
b845134151 user JSON encoding for browser logger
Fixes a strange issue in IE
2013-11-13 16:22:11 -05:00
Thomas Aylott
37bb9b76ab remove old browser logger 2013-11-13 16:22:10 -05:00
Thomas Aylott
39ba5f90b1 no need to pass jasmine through jsx 2013-11-13 16:22:10 -05:00
Thomas Aylott
e3ced21c9d postDataToURL using ajax instead of DOM 2013-11-13 16:22:10 -05:00
Thomas Aylott
66a0f2e7bd Suppress encoding warning in Firefox 2013-11-13 16:22:10 -05:00
Thomas Aylott
7c8b70eedb better error handling for jasmine task 2013-11-13 16:22:10 -05:00
Thomas Aylott
f12c428c78 NEW saucelabs webdriver task 2013-11-13 16:22:10 -05:00
Thomas Aylott
7ee30554ad ignore tunnel logs 2013-11-13 16:22:10 -05:00
Thomas Aylott
6b1042a6f9 fixup sauce-tunnel 2013-11-13 16:22:10 -05:00
Thomas Aylott
ff857efdd2 desiredCapabilities webdriver config 2013-11-13 16:22:10 -05:00
Thomas Aylott
0401a0a67c NEW sauce-tunnel grunt task 2013-11-13 16:22:10 -05:00
Ben Newman
5873ee7691 Merge pull request #526 from benjamn/rewrite-vendor/constants.js
Rewrite vendor/constants.js to use require("recast").types.traverse.
2013-11-13 12:39:53 -08:00
Ben Newman
da717977ed Better comments for vendor/constants.js. 2013-11-13 15:33:10 -05:00
Ben Newman
2b763fc452 Rewrite vendor/constants.js to use require("ast-types").traverse.
Most notably, this new style of transformation gives us access to
this.parent.node, which allows us to avoid replacing identifiers that are
not actually free variables, such as member expression properties.

Closes #496.
2013-11-13 15:33:10 -05:00
Ben Newman
b137a3326e Merge pull request #524 from brainkim/suchfailing-wow-sotest
Fix failing tests
2013-11-13 12:33:00 -08:00
Paul O’Shannessy
970445fc48 Merge pull request #522 from pieter-vanderwerff/blog-footer-position-fix
Added clearfix to blog content holder
2013-11-13 12:28:34 -08:00
Paul O’Shannessy
e716c2ee35 Merge pull request #493 from guidobouman/master
Prevent header anchors from interfering with clickable content in docs.
2013-11-13 12:23:57 -08:00
Brian Kim
e707ec0b1e Fix failing tests
Two of your tests were failing because of commit
1e71df5399
I fixed them by:
1) Using jasmine's spyOn in ReactCompositeComponentError-test.js
2) Inverting the function wrapping in the above commit.
Godspeed.
2013-11-13 05:07:52 -05:00
Pieter Vanderwerff
05d44b2152 Added clearfix to blog content holder 2013-11-13 15:01:32 +13:00
Paul O’Shannessy
797577576e Small cleanup to tips intro 2013-11-12 13:22:55 -08:00
Connor McSheffrey
bd535bd51c Renamed Cookbook references to tips. Reworded intro (sounded weird because it still referenced cookbooks. Updated some entry ID's (some side nav links didn't match entry permalinks) 2013-11-11 21:00:53 -08:00
Connor McSheffrey
166043593d Merge pull request #19 from chenglou/title-case
fix title case for tips everywhere
2013-11-11 20:19:33 -08:00
Tim Yung
9fd28f44df Rename nodeContains to containsNode 2013-11-11 16:39:25 -08:00
Mouad Debbar
1ffe2d0927 Add support for oncontextmenu in React. 2013-11-11 16:39:25 -08:00
Marshall Roch
735b4f0b7c Remove transaction from componentWillUpdate
It wasn't documented and I think the transaction is supposed to be internal.
2013-11-11 16:39:25 -08:00
Felix Kling
1e71df5399 Improve error logging for event handlers of React components.
This guards every auto-bound method and uses the name of the component and method as guard name.
2013-11-11 16:39:25 -08:00
Paul O’Shannessy
48948c91c3 Merge pull request #506 from syranide/wheelie8
Fix wheelDelta misspelled
2013-11-11 14:28:25 -08:00
Fabio M. Costa
1d73efee10 Fixes the name of the component on documentation
AvatarImage -> Avatar
2013-11-10 11:52:41 -08:00
Andreas Svensson
62f7cd213f Fix wheelDelta misspelled 2013-11-10 16:58:55 +01:00
Paul O’Shannessy
91f6684fbf Merge pull request #484 from syranide/jsxie8
IE8 support for JSXTransformer
2013-11-08 14:38:51 -08:00
Andreas Svensson
595b482478 JSXTransformer now supports IE8 2013-11-08 23:04:43 +01:00
Cheng Lou
ff51a23aea update add-ons docs based on feedbacks
- Overview of add-ons for the add-ons page.
- Better title for `ReactLink`.
- Nicer code format for classSet example.
- Better explanation for `classSet`.
2013-11-08 16:55:14 -05:00
petehunt
f7103a8629 Make state immutable in tutorial (eek) 2013-11-08 13:27:20 -08:00
Guido Bouman
4c9f9dafa6 Prevents header anchors from interfering with clickable content. 2013-11-08 15:52:46 +01:00
Pete Hunt
b65e6a0453 Merge pull request #492 from chenglou/move-tooling
move docs tooling from JSX in Depth
2013-11-07 11:36:19 -08:00
Cheng Lou
ca95c8c3a3 move docs tooling from JSX in Depth
Also removes the code wrap around the syntax highlighting link.
2013-11-07 14:25:54 -05:00
Thomas Aylott
3b8af033cd don't try to loadNpmTasks grunt-cli 2013-11-07 13:57:34 -05:00
Ben Newman
b3c87ea017 Merge pull request #451 from subtleGradient/subtlegradient/browser-testing
Browser testing.
2013-11-07 10:20:58 -08:00
Thomas Aylott
241d57aa9e allow directory browsing 2013-11-07 13:12:31 -05:00
Ben Newman
ee8bb07122 Merge pull request #486 from benjamn/jsx-version
Make bin/jsx --version output the React version according to package.json.
2013-11-07 07:52:54 -08:00
Ben Newman
c2ef6e343d Make bin/jsx --version output the React version according to package.json.
Closes #329.
2013-11-07 10:52:02 -05:00
Paul O’Shannessy
192af01952 Merge pull request #488 from spicyj/gh-473
Make submit button default value appear correctly
2013-11-06 22:56:19 -08:00
Paul O’Shannessy
5293a2ab1c Merge pull request #487 from spicyj/multi-proptypes
Make propTypes DEFINE_MANY_MERGED
2013-11-06 22:55:58 -08:00
Ben Alpert
d5c2d5f291 Make submit button default value appear correctly
Fixes #473.
2013-11-06 21:19:44 -08:00
Ben Alpert
4fe784de1f Make propTypes DEFINE_MANY_MERGED 2013-11-06 17:13:25 -08:00
Thomas Aylott
f289e9862a rename sauce-harness to index 2013-11-06 17:29:00 -05:00
Thomas Aylott
5fa707534a ignore generated file
Running the tests shouldn't make git status dirty.
2013-11-06 17:15:38 -05:00
Thomas Aylott
0a120bb5d0 cleanup loadNpmTasks 2013-11-06 17:12:20 -05:00
Thomas Aylott
19a5505c50 making phantomjs version less specific 2013-11-06 17:00:25 -05:00
Thomas Aylott
c9401be38e replace phantom-harness runner with webdriver 2013-11-06 16:44:03 -05:00
Thomas Aylott
b922d8d8a6 move browser test libs to lib folder 2013-11-06 16:43:20 -05:00
Vjeux
b8cf7068c4 Community round-up #10 2013-11-06 12:36:30 -08:00
Thomas Aylott
2d6a8391bf Not necessary anymore 2013-11-06 15:32:39 -05:00
Thomas Aylott
f4d487fb59 removed compiled build files
Not necessary now that we aren't supporting testling.
2013-11-06 15:30:52 -05:00
Thomas Aylott
be7ee1ee65 start a local webdriver server before using it 2013-11-06 15:30:52 -05:00
Thomas Aylott
3e2d3e4837 add logging to webdriver config 2013-11-06 15:30:52 -05:00
Thomas Aylott
dfb4dde8fd keep track of incomplete 2013-11-06 15:30:52 -05:00
Thomas Aylott
159d64ddd3 cleanup 2013-11-06 15:30:52 -05:00
Thomas Aylott
1368b29596 cleanup webdriver jasmine task 2013-11-06 15:30:52 -05:00
Thomas Aylott
c780985d3e wait for all results to finish sending 2013-11-06 15:30:52 -05:00
Thomas Aylott
71772e763a grunt task launch phantomjs as a webdriver server 2013-11-06 15:30:52 -05:00
Thomas Aylott
2d979a9ce9 cleanup 2013-11-06 15:30:52 -05:00
Thomas Aylott
2b273d8568 remove saucelabs for now 2013-11-06 15:30:51 -05:00
Thomas Aylott
b725097409 log using grunt 2013-11-06 15:30:51 -05:00
Thomas Aylott
772af52f4a safer bind 2013-11-06 15:30:51 -05:00
Thomas Aylott
db299ed761 remove sauce labs stuff for now 2013-11-06 15:30:51 -05:00
Thomas Aylott
0f274e5b22 new webdriver-jasmine task and config 2013-11-06 15:30:51 -05:00
Thomas Aylott
e086cbb44b separate grunt task for saucelabs browser testing 2013-11-06 15:30:51 -05:00
Thomas Aylott
93c0a46a1d upgraded sauce harness
Lost jasmine directly instead of using a module builder because it was failing in IE8
2013-11-06 15:30:51 -05:00
Thomas Aylott
2cd663940a don't double-log test results 2013-11-06 15:30:51 -05:00
Thomas Aylott
7bbf6cbfd1 browser support for jasmine-support 2013-11-06 15:30:51 -05:00
Thomas Aylott
46e86df420 move html reporter and its requirements 2013-11-06 15:30:51 -05:00
Thomas Aylott
d64f34b5d8 inserted iframes can be targeted after a delay 2013-11-06 15:30:50 -05:00
Thomas Aylott
f65f7b3bbd IE8 support in jasmine-support 2013-11-06 15:30:50 -05:00
Thomas Aylott
c4727944df Simple test result logger 2013-11-06 15:30:50 -05:00
Thomas Aylott
694cd6e9e8 test runner requires es5-shim 2013-11-06 15:30:50 -05:00
Thomas Aylott
465b8dc646 test server middleware for receiving test results 2013-11-06 15:30:50 -05:00
Thomas Aylott
284d8d67bd Upgrade to the latest version of jasmine
Necessary for IE8 support
2013-11-06 15:30:50 -05:00
Thomas Aylott
b111521f40 Correct SauceLabs tokens 2013-11-06 15:30:50 -05:00
Thomas Aylott
6a7a15cf30 disable testling 2013-11-06 15:30:50 -05:00
Thomas Aylott
3df6942cde SauceLabs Browser testing via Travis 2013-11-06 15:30:50 -05:00
Thomas Aylott
fc572832b1 Absolute urls for less flakiness 2013-11-06 15:30:49 -05:00
Thomas Aylott
46c0aeea67 Fixed paths for phantomjs 2013-11-06 15:30:49 -05:00
Thomas Aylott
a447f53b00 Make it easier to repro tests in the wild 2013-11-06 15:30:49 -05:00
Thomas Aylott
24ec78fd52 Testing-ci can't handle spaces in filenames? 2013-11-06 15:30:49 -05:00
Thomas Aylott
1393e55d53 include the built files for testling 2013-11-06 15:30:49 -05:00
Thomas Aylott
5640d641d6 skip Worker test unless the browser supports them 2013-11-06 15:30:49 -05:00
Thomas Aylott
ecd847cad7 enable testling-ci browser testing 2013-11-06 15:30:49 -05:00
Thomas Aylott
b867aa0410 Format test results as TAP 2013-11-06 15:30:49 -05:00
Thomas Aylott
8205c681eb serve worker.js from its actual relative path 2013-11-06 15:30:49 -05:00
Thomas Aylott
c4ba8f8997 Browser test runner 2013-11-06 15:30:49 -05:00
Thomas Aylott
001bda28d9 Generate the browser test list at built time 2013-11-06 15:30:49 -05:00
Paul O’Shannessy
1e7f3f1aac Merge pull request #483 from spicyj/sm-img
Use smaller blog images and host directly
2013-11-06 10:16:31 -08:00
Pete Hunt
28eddd1670 XML->HTML, because people are fickle. 2013-11-05 19:22:47 -08:00
Ben Alpert
a65f60a008 Use smaller blog images and host directly 2013-11-05 18:54:29 -08:00
Pete Hunt
091425058b Merge pull request #482 from chenglou/data-lowercase
add docs lowercase mention for data- and aria-
2013-11-05 18:10:56 -08:00
Cheng Lou
e89ad6c960 add docs lowercase mention for data- and aria- 2013-11-05 21:02:06 -05:00
Paul Shen
0fed861424 Move merge utility functions from utils to vendor/core 2013-11-05 17:17:47 -08:00
Tim Yung
e78d580c06 Include Ownership in the Ship of Theseus
When we determine whether a React component should be updated (as opposed to destroyed or replaced), we currently only look at whether they share the same constructor. This adds a check for whether they share the same owner component.

I've also consolidated this logic (I cannot believe this was not already done).
2013-11-05 17:14:57 -08:00
Pete Hunt
e78d5b5462 Merge pull request #481 from andreypopp/master
"Thinking in React": fix list formatting
2013-11-05 15:52:53 -08:00
Andrey Popp
20b7faaab7 "Thinking in React": fix list formatting 2013-11-06 03:50:28 +04:00
Paul O’Shannessy
5dad5e92a9 Merge pull request #476 from SanderSpies/unused-onselect
Removing unused useSelect variable.
2013-11-05 15:17:45 -08:00
Paul O’Shannessy
1553bad73a Move header link styling out of documentation only
It's used in blog posts too. I also constrained it to just the anchor
class to avoid any other headers we have.
2013-11-05 15:04:57 -08:00
Pete Hunt
aadb65166d Merge pull request #453 from petehunt/blogpost2
"Thinking in React" blog post
2013-11-05 14:26:25 -08:00
petehunt
c8bc605f9e rename 2013-11-05 14:25:46 -08:00
petehunt
486b60486a rename 2013-11-05 14:23:12 -08:00
petehunt
13f0644aaa make props/state section less intense 2013-11-05 14:21:15 -08:00
petehunt
780442f0b3 blogify 2013-11-05 14:21:15 -08:00
SanderSpies
27fa1f5c9c Removing 'isEventSupported' 2013-11-05 22:53:50 +01:00
SanderSpies
dede55d27d Removing unused useSelect variable. 2013-11-05 22:45:02 +01:00
Paul O’Shannessy
5c6c02fe03 Merge pull request #472 from lrowe/patch-4
Script async and defer properties
2013-11-05 11:48:54 -08:00
Paul O’Shannessy
9f3ef1b6ac Remove jQuery version number from tutorial docs 2013-11-05 11:29:00 -08:00
Ben Alpert
5386cd9665 tutorial: Simplify ajax options
dataType was unnecessary; mimeType was both unnecessary and wrong in this case. Also removed an unnecessary bind and changed pollInterval to 2000 ms for consistency with https://github.com/petehunt/react-tutorial (faster is nicer if you actually try it out!).
2013-11-05 11:17:37 -08:00
Cheng Lou
f2ee3c53a9 fix title case for docs tips everywhere 2013-11-05 09:57:00 -05:00
Laurence Rowe
1bcca22719 Script async and defer properties 2013-11-04 20:40:53 -08:00
petehunt
6c1e8e8a66 Update tutorial to use className 2013-11-04 17:04:25 -08:00
petehunt
9f69b12e5b get rid of composition 2013-11-04 12:22:43 -08:00
Ben Newman
ff3c8ccbe6 Merge pull request #458 from chenglou/rm-wrapup
Remove support for the wrapup packager.
2013-11-04 11:41:59 -08:00
Paul O’Shannessy
da5c61afe4 Oxford comma 2013-11-04 11:34:56 -08:00
Josh Duck
18bf0b80bc Fix ReactDOMSelection for IE 11
IE 11 no longer supports the legacy document.selection API.
Their implementation of window.getSelection() doesn't support
the extend() method, which we were relying on.

If the selection is RTL and selection extend is missing, then just
flip the selection.
2013-11-04 11:34:39 -08:00
Cheng Lou
d220ce71b5 Merge branch 'rm-wrapup' of github.com:chenglou/react into rm-wrapup
Conflicts:
	package.json
2013-11-03 15:43:56 -05:00
Cheng Lou
d6cbc710bd remove examples/wrapup
Apparently it's no longer relevant.
2013-11-03 15:41:40 -05:00
Paul O’Shannessy
10ccd9f103 Merge pull request #465 from matnel/bug388
Clear error message when rendering a nonvalid component
2013-11-01 18:35:50 -07:00
Matti Nelimarkka
9e24257a4e Clear error message when rendering a nonvalid component 2013-11-01 17:32:09 -07:00
Paul O’Shannessy
aedf580a33 [docs] Clarify when getInitialState is called. 2013-11-01 15:29:10 -07:00
petehunt
f713f06c62 less aggro 2013-11-01 11:47:38 -07:00
Cheng Lou
899ae83acb add docs on classSet add-on 2013-10-31 21:59:35 -04:00
Cheng Lou
3c1e0f0a8c split add-ons into subsections
In preparation for documenting `classSet` add-on.
2013-10-31 21:10:19 -04:00
Tim Yung
0dc011c40c Better getUnboundedScrollPosition for windows
Instead of using browser sniffing, `getUnboundedScrollPosition` can do
better and not have to depend on the `getDocumentScrollElement` module.
2013-10-31 15:24:58 -07:00
Cheng Lou
e455e28ff8 fix doc & example transition opacity from .99 to 1
The initial thought was that an opacity animation from 0.01 to 1 causes trouble on some browser. But after testing on opera 12.15, ff 23, ie 10, chrome 30, desktop/mobile safari 7 and chrome android I confirm this works.
2013-10-31 17:35:38 -04:00
JeffMo
a4f8ad1bb0 Switch utility function calls -> namespaced calls 2013-10-31 13:45:16 -07:00
Cheng Lou
0acf5e22bd remove examples/wrapup
Apparently it's no longer relevant.
2013-10-31 15:49:37 -04:00
Ben Newman
df1099649c Merge pull request #457 from benjamn/upgrade-populist
Bump populist version to v0.1.4
2013-10-31 10:22:14 -07:00
Ben Newman
d1ad4a3ff0 Bump populist version to v0.1.4.
The new version includes a fix for this IE8 issue reported by
@subtleGradient: https://github.com/benjamn/populist/issues/4

Closes #456.
2013-10-31 13:03:31 -04:00
Paul O'Shannessy
2cf7d943df Reorder DefaultDOMPropertyConfig
`autoCorrect` belongs with the non-standard properties list.
2013-10-30 16:58:05 -07:00
Mark Richardson
9b44ad6ce5 Add autoCorrect to list of supported DOM properties 2013-10-30 16:57:53 -07:00
Tim Yung
7789a32438 Forward Compatibility w/ WebKit & Blink
Newer versions of WebKit and Blink will support both `document.body.scrollTop` and `document.documentElement.scrollTop`. Therefore, implementing cross-browser compatibility by summing the two will no longer work.

This changes React to use `getUnboundedScrollPosition` so we get the fix and consistency in one change!

See: https://rniwa.com/2013-10-29/web-compatibility-story-of-scrolltop-and-scrollleft/
2013-10-30 16:56:55 -07:00
Connor McSheffrey
551cc01430 Update nav config with new entry names/permalinks 2013-10-30 12:29:38 -07:00
Connor McSheffrey
22058d09da Merge pull request #18 from chenglou/title-case
title case for entry titles; fix two entry names
2013-10-30 12:24:50 -07:00
Cheng Lou
80efa9a33e title case for entry titles; fix two entry names 2013-10-30 15:06:16 -04:00
Connor McSheffrey
6a0976ca9d Merge pull request #17 from chenglou/feat-documentation-cookbook
fix 3 more entries
2013-10-29 18:10:56 -07:00
Connor McSheffrey
5847536c9d Removed grunt task for building live edits and removed js link conditional at bottom of layout since we're no longer conditionally loading live edit js for cookbook pages 2013-10-29 18:04:29 -07:00
Paul O’Shannessy
a5d1e2fd90 blog post for 0.5.1 2013-10-29 13:16:53 -07:00
Paul O’Shannessy
d8e3779010 Update everything for v0.5.1
Cherry-picked from f3db0006e8, excluding
version changes.
2013-10-29 13:15:33 -07:00
Cheng Lou
7d50ab600f ex for entry 7 2013-10-29 14:55:11 -04:00
Connor McSheffrey
e3ec6f5292 Removed JS for live edit 2013-10-29 11:28:28 -07:00
Cheng Lou
9471287794 Merge branch 'feat-documentation-cookbook' of https://github.com/mcsheffrey/react into feat-documentation-cookbook 2013-10-29 14:23:17 -04:00
Cheng Lou
cbec8c1a89 fix 2 more entries 2013-10-29 14:20:04 -04:00
Connor McSheffrey
4a7d8f628e Removed .js extension from Cookbook Introduction description 2013-10-29 11:09:57 -07:00
Connor McSheffrey
b025e4c576 Merge pull request #16 from chenglou/feat-documentation-cookbook
new line at end of nac_docs; update to entry 4
2013-10-29 11:06:14 -07:00
Cheng Lou
ee8fa3760d new line at end of nac_docs; update to entry 4 2013-10-29 14:02:20 -04:00
Connor McSheffrey
efaba68663 Removed Q&A format 2013-10-29 10:42:47 -07:00
Connor McSheffrey
33effd31d5 Removing the grunt task generated live edit JS files since we're holding off on the inline edit feature for now 2013-10-29 10:15:45 -07:00
Cheng Lou
271e7d50cf better grammar 2013-10-29 10:15:45 -07:00
Cheng Lou
c235ec7421 entry on false behavior 2013-10-29 10:15:45 -07:00
Connor McSheffrey
6e28818ba9 Remove cb prefix from cookbook entries since they're already in /cookbook/ directory 2013-10-29 10:15:45 -07:00
Connor McSheffrey
95f3caaaa4 removed cookbook prefix from filenames 2013-10-29 10:15:45 -07:00
Connor McSheffrey
a7dd6e7c70 better regex for filename 2013-10-29 10:15:45 -07:00
Connor McSheffrey
30ab347b78 undo changes to extractCode, using grunt task instead 2013-10-29 10:15:45 -07:00
Connor McSheffrey
9585c407e2 added function that write to the output html file 2013-10-29 10:15:45 -07:00
Connor McSheffrey
9efd1f5e9b added seperate cookbook layout (since URL base of next/prev is hardcoded in layout), added next/prev yaml meta to each cookbook entry until I can find a way of generating them dynamically 2013-10-29 10:15:45 -07:00
Connor McSheffrey
21c5c2a54e update cookbook nav 2013-10-29 10:15:45 -07:00
Cheng Lou
a970957eef remove entry 13 jquery animation; react has animation 2013-10-29 10:14:21 -07:00
Cheng Lou
119e29ff1d one single child in ternary 2013-10-29 10:14:21 -07:00
Cheng Lou
7db760427c add lib integration entry; tweak 1 sentence 2013-10-29 10:14:20 -07:00
Cheng Lou
6d2ea9a200 ajax ex 2013-10-29 10:14:20 -07:00
Cheng Lou
0475834470 fix all links to point to /react as root 2013-10-29 10:14:20 -07:00
Cheng Lou
48f1ee4940 change some wording, add tip for events entry
- No need to mention React, you know you're working with it =).
- Wrap code elements in back ticks, so that they get the "box" styling for md.
- You'd want the snippet to work inside the live editor, so you need to `renderComponent`. As per wiki specification, the DOM element on which to mount is `mountNode`, just like on the front page.
- Don't forget the JSX pragma, or else your `render` fails.
- Nitpick: empty line after the end of md.
- No need for jQuery reference since
  1. The general mood around React is that you don't need jQuery.
  2. The syntax' still clear without jQuery.
  3. We're doing a jQuery integration entry =).
- `getInitialState` was absent.
- You don't need `componentWillMount` here. fetch them in `getInitialState`.
- The non-spoken convention seems to call the event handler `"handle" + eventName`. So `handleResize` clearly indicates it's a `resize` handler while `updateDimensions` might do something else. This latter name might actually be better under circumstances where you use call the method directly somewhere, but since we removed the only direct usage in `componentWillMount` this is fine.
- Went OCD again and tried to keep the code short. `width` is enough of a demo. Removed `height`.
- Distinguish between DOM events and React events. Wish we go full React events in a near future.
2013-10-29 10:14:20 -07:00
Cheng Lou
fb5f69f44e modify some wording 2013-10-29 10:14:20 -07:00
Connor McSheffrey
e0df9cbb01 Add event listeners cookbook entry 2013-10-29 10:14:20 -07:00
Cheng Lou
1e56800543 shrink working on props in state entry 2013-10-29 10:14:20 -07:00
Cheng Lou
28f30b7ef0 props in getInitialState as anti-pattern 2013-10-29 10:14:20 -07:00
Connor McSheffrey
86355eb1ba added grunt task for generating live samples JS 2013-10-29 10:14:20 -07:00
Cheng Lou
bfbcb5362b tip format for intro 2013-10-29 10:14:20 -07:00
Cheng Lou
8d2b4a9a25 all typos 2013-10-29 10:14:20 -07:00
Connor McSheffrey
da722b92c0 Added backgroundImage example to "inline styles" cookbook entry 2013-10-29 10:14:20 -07:00
Connor McSheffrey
a4d7f3f907 minor spelling change on the "controlled input null value" cookbook entry 2013-10-29 10:14:20 -07:00
Cheng Lou
6377b2ed95 entry on willReceiveProps not triggered on mounting 2013-10-29 10:14:19 -07:00
Cheng Lou
dd52ef92a8 entry on controlled input with value null 2013-10-29 10:14:19 -07:00
Cheng Lou
9ed72b43e8 add line-height to unitless css props 2013-10-29 10:14:19 -07:00
Cheng Lou
f4bbe9c296 style prop value shorthand, children prop manip warning 2013-10-29 10:14:19 -07:00
Cheng Lou
814126dc52 entry on returning only one node from render 2013-10-29 10:14:19 -07:00
Cheng Lou
ff9246316f fix permalink, temporarily remove script field of Jekyll 2013-10-29 10:14:19 -07:00
Cheng Lou
b92c433c50 small typo and code tag is now js highlight
Was html before bc github screws up the js highlighting for jsx.
2013-10-29 10:14:19 -07:00
Cheng Lou
7144ba1c10 new entry on self-closing tag 2013-10-29 10:14:19 -07:00
Cheng Lou
0fad22512a new entry for ternary expression in jsx 2013-10-29 10:14:19 -07:00
Cheng Lou
4d9cde43be add tip format for comparison 2013-10-29 10:14:19 -07:00
Cheng Lou
dc24bb63d6 add tip style to style entry 2013-10-29 10:14:19 -07:00
Connor McSheffrey
5f296768a5 Moved cookbook recipes into separate directory. Updated nav_docs to loop through cookbook yaml. Added cookbook directory to js/ to add live editing of code samples 2013-10-29 10:14:19 -07:00
Connor McSheffrey
dd5fbc5859 Added docs for React cookbook section Introduction and Inline Styles React recipe 2013-10-29 10:14:18 -07:00
Laurence Rowe
280eff41f3 Make 'disabled' MUST_USE_ATTRIBUTE for compatibility with CSS [disabled] selectors.
When a ReactDOMComponent is created with the property `disabled: true` subsequently setting the property to `disabled: false` the HTML attribute `disabled="true"` was being left in the DOM.
2013-10-28 18:53:19 -07:00
Paul O’Shannessy
214e9103bf Merge pull request #423 from andreypopp/master
Re-rendering components into a document leaks components
2013-10-28 17:00:19 -07:00
Andrey Popp
ac9dd92272 Fix unmounting components mounted into doc element
If we are to unmount a component mounted into a document element we should
unmount it from document.documentElement and not from document.firstChild which
is a doctype element in this specific case.
2013-10-29 02:49:00 +04:00
Ben Alpert
25ba629098 Move heading anchors 50px up to avoid nav bar
Fixes #447.

We do this by moving the actual anchored element up in the page without moving the actual text. (Apple uses a similar trick in their framed docs.) Now this looks a bit sillier on smaller screens but it's better overall.
2013-10-28 13:52:58 -07:00
petehunt
91d23ffc58 typo 2013-10-28 10:21:11 -07:00
Paul O’Shannessy
10f3d93df7 Update API docs for unmountAndReleaseReactRootNode 2013-10-26 17:42:34 -07:00
Pete Hunt
1c77e1a492 Merge pull request #446 from brianr/master
ReactTransitionGroup example: fix typo and logic bug in handleRemove
2013-10-25 18:13:46 -07:00
Ian Obermiller
fbb741febb Fix ReactTransitionEvents detectEvents 2013-10-25 18:11:58 -07:00
Brian Rue
c5cc145538 ReactTransitionGroup example: fix typo and logic bug in handleRemove 2013-10-25 18:03:31 -07:00
Cat Chen
0ef1ca0024 fixed %d in invariant call 2013-10-25 18:03:26 -07:00
petehunt
0a75a52b4a Changes based on feedback 2013-10-25 11:40:54 -07:00
Josh Duck
0d2d3360d0 Don't reset mouseDown in focus handlers
Focus fires after mouse down on initial click, so we lost the
flag when the user initially began dragging on the input.
2013-10-22 14:09:33 -07:00
petehunt
15de778587 New marketing copy 2013-10-21 22:08:43 -07:00
Keito Uchiyama
eeefe95958 docs: Delete Mutation Events (onCharacterDOMModified) 2013-10-21 19:56:49 -07:00
Paul O’Shannessy
5e65c186aa docs: remove OUTLINE 2013-10-21 15:20:01 -07:00
Cheng Lou
99dcdb87e3 Add clickable anchors to docs headers
Closes #434
2013-10-21 14:27:31 -07:00
Tim Yung
58b3ae3136 Use Default Value for Undefined Props
Currently, default props as defined by `getDefaultProps` are only used if a prop is not specified (using `X in Y` check).

However, this makes it difficult for composing components to pass along the state of not being defined, for example:

  render: function() {
    // If `this.props.someProp` is not set, `InnerThing` should use the default value.
    return <InnerThing someProp={this.props.someProp} />;
  }

This changes the requirement for falling back to the default value to an undefined check (using `typeof X === 'undefined'`).
2013-10-21 13:17:44 -07:00
Pete Hunt
7d6b0dd613 Merge pull request #438 from spicyj/select-range
Make SelectEventPlugin not throw for range inputs
2013-10-21 09:39:39 -07:00
Ben Alpert
893fba8373 Make SelectEventPlugin not throw for range inputs
Accessing .selectionStart on a non-text input will throw (see http://www.w3.org/TR/2009/WD-html5-20090423/editing.html#textFieldSelection), so check that the input has selection capabilities before accessing the property.

Fixes #437.
2013-10-20 14:39:37 -07:00
Paul O’Shannessy
b46b6a8db9 Fix live editor examples on home page.
Remember that one time I wrote release notes and said:

> This is a breaking change - if you were using class, you must change
> this to className or your components will be visually broken.

Good thing I didn't listen to myself!
2013-10-16 17:56:51 -07:00
Paul O’Shannessy
44ad2b55e6 0.5.0 release
Updated README, CHANGELOG, blog post
2013-10-16 11:43:09 -07:00
Paul O’Shannessy
820532b7aa Fix grunt npm:test 2013-10-16 11:42:02 -07:00
Paul O’Shannessy
48281a17e4 bump version to 0.6.0-alpha 2013-10-15 22:39:28 -07:00
Paul O’Shannessy
d8c949e4d8 Update browserify 2013-10-15 21:27:26 -07:00
JeffMo
243a2b816e bump baseline jstransform and esprima dependency versions 2013-10-15 18:54:01 -07:00
Paul O’Shannessy
451176665c Update docs with supported tags and attributes 2013-10-15 18:15:24 -07:00
Paul O’Shannessy
cff62f8d72 Enable linting for bitwise operators 2013-10-15 18:02:28 -07:00
Paul O'Shannessy
3f2ba221ef Use getActiveElement module
We had something that did the same sort of protection. The module
differs slightly (returns document.body instead of undefined) but
looking at the callers, that should be ok.
2013-10-15 18:00:05 -07:00
Paul O'Shannessy
46713c3d7d Fix Lint
Enabling bitwise linting caught another user. Also fixed a semicolon
misuse.
2013-10-15 17:59:14 -07:00
Paul O’Shannessy
b015204938 Updated AUTHORS for 0.5
closes #414
2013-10-15 15:01:14 -07:00
petehunt
24f6bed855 new addons docs
closes #403
2013-10-15 14:09:21 -07:00
Paul O’Shannessy
5325e944e9 Merge pull request #426 from SanderSpies/sspi-fix-jsx-doc-link
In-browser JSX warning linked to wrong anchor (should be lowercase)
2013-10-15 12:04:59 -07:00
Paul O’Shannessy
b488cb3d4b Merge branch 'SanderSpies-sspi-dom-attribute-process' 2013-10-15 12:00:52 -07:00
Paul O’Shannessy
087c2afed1 Make sure DOM components work in JSDOM 2013-10-15 11:38:26 -07:00
Paul O’Shannessy
b0645bd5d3 Be consistent with object naming in tests
This also fixes line length issues our linter was complaining about.
2013-10-15 11:38:26 -07:00
SanderSpies
5a13dd090d Standardize prop -> DOM attribute process
Allow more than strings and numbers to be used as attributes for DOM
nodes. This removes the special casing for `0` and `false` that was
being used in ReactDOMInput and ReactDOMTextarea.

Now we will just `toString` any object we try to insert into a DOM.

Closes #422, #372, #302
2013-10-15 11:38:25 -07:00
Paul O'Shannessy
b0455f4670 Ensure attribute values are strings
`jsdom` behavers differently than browsers here and we should ensure
that we are consistent. Browsers should be (and are) converting to
a string first, while `jsdom` doesn't.
2013-10-15 10:39:51 -07:00
Tim Yung
287f5b578c Add bitwise lint escape to DefaultDOMPropertyConfig 2013-10-15 10:38:31 -07:00
SanderSpies
6839704c4b #JSX => #jsx 2013-10-15 19:11:19 +02:00
Martin Konicek
5332422239 [docs] Fix a broken link to JSX syntax in README. 2013-10-14 17:10:26 -07:00
Ben Alpert
7909c3e71b Forcibly wrap SVG nodes with <svg> on creation
Forcing wrapping seems necessary here: I compared a <circle> created within a <div> with a <circle> created inside an <svg> and they appear to have exactly the same properties with the exception of .parentNode (and .parentElement), yet the former refuses to show up when appended to an <svg> element. As such, I can't find any useful way to write a unit test (testing getMarkupWrap's output doesn't seem particularly useful to me).

Fixes #311.

Test Plan:
With a component that adds a <circle> after mounting (such as http://jsfiddle.net/spicyj/hxFVe/), verify that the circle appears in both Chrome and IE9.
2013-10-14 13:44:36 -07:00
Paul O’Shannessy
b45c82c256 Merge pull request #419 from piranha/svg-attrs
svg properties -> attributes

Fixes #190
2013-10-14 11:24:36 -07:00
Alexander Solovyov
3a5a82fd18 DefaultDOMPropertyConfig: sort properties alphabetically 2013-10-14 20:45:00 +03:00
Josh Duck
1238f5f23a Remove DOM mutation listeners
Mutation listeners are known to be slow. Rough benchmarks show text
changes are now 50% faster.
2013-10-11 17:33:47 -07:00
Owen Coutts
ac9f5e9da4 Better click behavior for ff
Firefox created onClick events for right mouse clicks. This diff brings behavior on firefox inline with other browsers.
2013-10-11 15:42:22 -07:00
Josh Duck
58c392ae3b Check for null selection
getRangeAt(0) will throw on null selection. Add guard in
ReactDOMSelection and DocumentSelection.
2013-10-11 12:52:19 -07:00
Alexander Solovyov
aa38ffc22d svg attributes properly cased when assigned by react 2013-10-11 15:48:17 +03:00
Alexander Solovyov
6d300527c8 svg: rx/ry for rounded corners 2013-10-11 13:42:10 +03:00
Alexander Solovyov
a601c5cc81 svg properties -> attributes 2013-10-11 13:32:22 +03:00
Alexander Solovyov
4549fd7510 fix namesToPlugins for gcc advanced mode 2013-10-09 22:08:03 +03:00
Keito Uchiyama
ef60eee57a Make transferPropsTo() message easier to debug
Summary:
Made the transferPropsTo() error introduced in
325322898c easier to use to debug.
2013-10-09 11:28:35 -07:00
Sebastian Markbage
7a9c13dee8 Set _renderedComponent before it's fully mounted
For debugging so that we can inspect the currently rendering tree. I think this
should be safe and makes sense since it tried to mount.
2013-10-09 11:28:22 -07:00
Tim Yung
d652dd928a Add displayName for DOM Components 2013-10-09 11:28:12 -07:00
Jan Kassens
c99d6a8013 Make the injection of ReactPerf work
The injection was only evaluated when ReactCompositeComponent was first loaded.
This made it impossible to inject a custom measure and the injection pointless.
2013-10-09 11:27:40 -07:00
Ben Newman
f8c5752472 Merge pull request #374 from spicyj/workers
Test that React loads properly in a web worker.

Most of this code is open source-only, so I think it's safe to merge without figuring out how to translate it upstream first.
2013-10-09 08:50:41 -07:00
Paul O’Shannessy
44352a2861 Merge pull request #370 from zpao/addons
react-with-addons build
2013-10-08 16:54:31 -07:00
Paul O’Shannessy
7da874d835 Add TransitionGroup example 2013-10-08 16:49:11 -07:00
Paul O’Shannessy
de9e94de5f Make sure react-with-addons ends up in react-source gem 2013-10-08 16:49:11 -07:00
Paul O’Shannessy
a151133161 Make sure react-with-addons ends up in bower 2013-10-08 16:49:11 -07:00
Paul O’Shannessy
042a2723ff Make sure addons builds are sent to build server 2013-10-08 16:49:11 -07:00
Paul O’Shannessy
2e6092b217 react-with-addons build
This creates a new standalone build which should have everything the
default build has, plus a little extra. This is not a sustainable long
term solution (we shouldn't make people choose like this) but it fixes
the problem we have in the short term.

This also removes the terrible react-transitions build. This is better
anway.

Fixes #369
2013-10-08 16:49:11 -07:00
Ben Alpert
f658c32df1 Tweak verbiage about required polyfills
I found it weird how the es5-shim comment came after the list of functions; now it's before.
2013-10-08 16:25:29 -07:00
Paul O’Shannessy
b16874c5a8 Merge pull request #407 from Samangan/master
renamed ReactOnDOMReady module to ReactMountReady
2013-10-08 15:12:29 -07:00
Connor McSheffrey
b9a657db2c fixed broken link on Community Round-up #9 blog post
closes #409
2013-10-08 11:09:33 -07:00
Josh Duck
dbc613199b Fix SelectEventPlugin
There were 2 issues:

I was reusing event outside the original event handler (activeNativeEvent).
This is a bad idea. I've changed deferred dispatch to have an empty object
as the nativeEvent.

I didn't handle inputs without .selectionStart (e.g. file inputs). I extracted
a input type check from ChangeEventPlugin and reuse it here.
2013-10-08 10:28:43 -07:00
Paul O’Shannessy
920c4206f4 Sync getActiveElement module from FB. 2013-10-07 15:32:47 -07:00
Paul O’Shannessy
fdb10c0679 React.__internals
We need access to internal modules in order to provide a single way for some
projects to work internally with @providesModule and externally.
2013-10-07 15:07:20 -07:00
Pete Hunt
325322898c Throw when calling transferPropsTo() on a component you don't own
This is dangerous because it means that data is flowing into the component from two components, only one of which is the actual "owner". While we may be able to figure out how to
support this someday, let's be strict and prevent it for now.
2013-10-07 15:07:04 -07:00
Sebastian Markbage
27669c09ca Move flattenChildren into MultiChild 2013-10-07 15:06:44 -07:00
Tim Yung
0c59c57d66 Speed Key Validation (by over 9000)
Use a valid identifier (and non-string) to reduce chance of de-optimizing in V8 and Nitro.
2013-10-07 15:05:56 -07:00
Christopher Chedeau
26d7c4275a Add warning when using componentShouldUpdate 2013-10-07 15:05:44 -07:00
Josh Duck
2b7a7599bb Add select event plugin
Polyfill 'onSelect' behavior for React.

Use non-standard 'selectionchange' event rather than 'select' event.
This allows us to fire the event when user moves the cursor via arrow
keys, and not just when they select multiple chars.

Add methods to ReactDOMSelection to make getting current selection
easier, so we can do a fast check for change without having to
calculate char offsets for selection start and end.
2013-10-07 15:02:57 -07:00
Sebastian Markbage
ed9c0ca87c Expose bound function, context and arguments
Exposes the bound context, original method and bound arguments for any
auto-bound methods, for debugging purposes.
2013-10-07 15:02:47 -07:00
Sebastian Markbage
68abbacc39 Expose the rendered children before they're actually mounted
Exposing the _renderedChildren property before all the children are fully
mounted. This allows us to debug a partially mounted tree when the debugger
has a breakpoint in the one of the mounting children.

This only has a functional difference in the case where mounting throws. This
will end up not mounting the component anyway. Any remounting shouldn't be
affected by this change.
2013-10-07 15:02:27 -07:00
Samangan
84d8e1841a renamed ReactOnDOMReady module to ReactMountReady
fix

renamed ReactOnDOMReady module to ReactMountReady
2013-10-05 01:35:56 -05:00
Vjeux
a9b3139ff8 Community round-up #9
http://fooo.fr:4000/react/blog/2013/10/03/community-roundup-9.html
2013-10-03 15:18:21 -07:00
Vjeux
582b720183 Add app id for comments moderation
This way we can be notified when any new comment appear in the docs/blog and add moderators
2013-10-03 22:32:20 +02:00
Ben Newman
0a02b55d95 Use nodeContains where appropriate. 2013-10-01 17:55:13 -07:00
Tim Yung
20af6a7ce8 Speed Owner Access (by over 9000)
Use a valid identifier (and non-string) to reduce chance of de-optimizing in V8 and Nitro.
2013-10-01 16:32:06 -07:00
Ben Newman
7c0f5c3237 Fix isEventSupported in recent versions of jsdom.
Setting the `eventName` attribute of an element to the empty string is not
enough to cause `typeof element[eventName] === 'function'` in jsdom. The
attribute value actually has to look like a function body.
2013-10-01 16:31:46 -07:00
Paul O'Shannessy
f43449d333 ReactNativeComponent -> ReactDOMComponent
In an effort to break the DOMy parts of React away from the non-DOMy parts, I'm renaming this.
2013-10-01 16:31:32 -07:00
Ben Newman
e66287f92e Copy the nodeContains module from static_upstream. 2013-10-01 19:18:09 -04:00
Paul O’Shannessy
f20626f17a Merge pull request #378 from spicyj/html-reconciliation
Fix reconciling when switching to/from innerHTML
2013-10-01 13:38:08 -07:00
Andrew Zich
ab00f8d15c Removed "ajaxify" from DefaultDOMPropertyConfig
The `"ajaxify"` attribute is Facebook-specific and does not belong in this repo.
2013-10-01 13:34:26 -07:00
Pete Hunt
58de758a32 Sort batched updates by owner depth
If we reconcile components higher in the hierarchy they will likely reconcile components lower in the
hierarchy. If we sort by depth then when we reach those components there will be no more pending state or
props and it will no op.
2013-10-01 13:33:12 -07:00
Paul O’Shannessy
8beaa211fb Merge pull request #387 from spicyj/exec-fix
Actually make exec work
2013-10-01 13:14:56 -07:00
Paul O’Shannessy
7c217324a6 Merge pull request #384 from chenglou/doc-link
Add doc link to DOM differences from JSX gotchas
2013-10-01 11:25:34 -07:00
Paul O’Shannessy
15c1358aaf Merge pull request #386 from chenglou/unitless-line-height
add line-height to unitless css props, test cases
2013-10-01 10:35:21 -07:00
Ben Alpert
0a45325621 Actually make exec work
The spec for eval (http://es5.github.io/x15.1.html#x15.1.2.1) says "If Type(x) is not String, return x." and that's exactly what's happening here -- it gets {code: ...} and does nothing.
2013-09-30 18:51:39 -07:00
Cheng Lou
607eeaed4b Add doc link to DOM differences from JSX gotchas 2013-09-30 20:46:41 -04:00
Paul O’Shannessy
c764adc256 Merge pull request #376 from spicyj/noglobal
Fix lint errors including use of `global`
2013-09-30 14:21:12 -07:00
Cheng Lou
27ee9c6eb0 add line-height to unitless css props, test cases 2013-09-30 13:56:56 -04:00
Pete Hunt
8835e9d99f Update README.md 2013-09-28 19:57:18 -07:00
Ben Alpert
3ca507d73f Fix reconciling when switching to/from innerHTML
There's no way that this can work if _updateDOMChildren doesn't know about dangerouslySetInnerHTML, so tell it.

Fixes #377.
2013-09-27 16:22:46 -07:00
Ben Alpert
3dc1074908 Test that React loads properly in a web worker
This should catch top-level uses of `window` and `document`, while lint rules catch `global`.
2013-09-27 14:38:11 -07:00
Ben Alpert
94d2bbb221 Fix lint errors including use of global 2013-09-26 16:55:26 -07:00
Pete Hunt
84dea7e971 Fix server rendering 2013-09-26 15:49:19 -07:00
Pete Hunt
781bbe2916 Merge pull request #375 from danielmiladinov/master
Change spec policy for getDefaultProps to SpecPolicy.DEFINE_MANY_MERGED
2013-09-26 13:45:34 -07:00
Daniel Miladinov
b0ae800d64 Change spec policy for getDefaultProps to SpecPolicy.DEFINE_MANY_MERGED
This will allow multiple mixins for a component to define
getDefaultProps and their values will be merged.

See also:
https://groups.google.com/d/msg/reactjs/UzSiXw2Vo5s/FxK7AHWOzLMJ
2013-09-25 23:52:29 -04:00
Paul O’Shannessy
848a8e1180 Remove animation "example"
It was never a real example and shouldn't have been checked in.
2013-09-25 11:08:24 -07:00
Paul O’Shannessy
fc0b68af28 Fix 404s to non-existent API docs 2013-09-24 16:00:52 -07:00
Paul O’Shannessy
c6f831e85f Redirect docs/reference.html 2013-09-24 15:47:17 -07:00
Vjeux
58173edb16 Community round-up #8 2013-09-24 14:18:11 -07:00
Pete Hunt
fc73bf0a0a ReactLink: two-way binding for React
This introduces `ReactLink` which is a super lightweight way to do two-way binding for React.

If you want to use a controlled form input today, it's a lot of lines of code:

http://jsfiddle.net/T3z3v/

Look how many times `name` is repeated in there. And you have to remember to wire up event handles and pass the right state and
right event handler for *each* form field. It's really annoying.

With ReactLink, you can "link" a form value to a state field. It's just some simple sugar around the value prop/onChange
convention:

https://gist.github.com/petehunt/6689857

Ah, much nicer! And requires very little core changes or extra bytes. `ReactLink` just wraps the current value and "request
change" handler into a little object and provides some sugar to create some from composite component state.
2013-09-24 12:14:25 -07:00
Marshall Roch
458836abd3 Fix use of 'window' in CompositionEventPlugin
access to `window` needs to be guarded by `ExecutionEnvironment.canUseDOM`.
2013-09-23 23:01:14 -07:00
Josh Duck
5d7633d74c Move composition event to plugin with polyfill
Move compositionstart/compositionend to a new event plugin.

Add a polyfill that listens to key and mouse events and uses selection to
determine which text has changed.
2013-09-23 16:27:01 -07:00
Josh Duck
8f15eea910 Add ReactDOMSelection module
Add a DOM based selection module. This can both be used on its own and
in ReactInputSelection where our current implementation is lacking.

There is still some inconsistency with how IE and modern browsers
handle block nodes. Should be OK if we are just getting and setting
and not trying to set selection based on character offsets.
2013-09-23 16:23:35 -07:00
Paul O’Shannessy
d27746ee0b Docs: Give headers ids for easy linking
This gives markdown headers an id so that we can link directly to
sections of our docs. This is better than the alternative of adding them
all ourselves.
2013-09-23 10:30:51 -07:00
Keito Uchiyama
d13ce702a8 Fix typo in doc 2013-09-22 15:09:36 -07:00
Keito Uchiyama
d262285827 Fix use of "it's" in docs 2013-09-22 13:24:25 -07:00
Jeff Morrison
b5a11a431e Merge pull request #336 from spicyj/jsx-spacing
JSX: Respect original spacing and newlines better
2013-09-20 10:59:21 -07:00
Pete Hunt
832d9de037 Rename unmountAndReleaseReactRootNode() -> unmountComponentAtNode()
This is just a better name; we may revisit the name later.
2013-09-19 14:46:49 -07:00
Josh Duck
578863881f Add composition events to React.
Composition events make it possible to detect IME entry/exit.
https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent
2013-09-19 14:30:21 -07:00
Paul O’Shannessy
8875e1dc3b Merge pull request #359 from SanderSpies/master
Give the user a warning when using unoptimized JSX code
2013-09-19 13:14:12 -07:00
SanderSpies
cd79ed32cb - removed creation of the id within the tooling integration doc (expect this to be done by @zpao's pull request)
- removed the if statement and now always provide a warning message (as proposed by @spicyj)
- improved the warning message
2013-09-19 06:48:38 +02:00
SanderSpies
1924b7c945 Correcting the markdown anchor 2013-09-19 00:58:37 +02:00
SanderSpies
d2bf50c63d Give the user a warning when using unoptimized JSX code and send the user to the correct location in the documentation to optimize. 2013-09-19 00:55:10 +02:00
Ben Newman
b1dd4149a0 Merge pull request #343 from benjamn/fix-if-statement-pruning
Make constant propagation smarter about pruning if statements
2013-09-18 11:10:56 -07:00
Paul O’Shannessy
208ebd35b7 Don't update the docs version by default
This was leading to a lot of unnecessary churn in the config file since
different YAML versions were serializing differently.
2013-09-18 10:40:12 -07:00
Ben Newman
adda400602 Make constant propagation smarter about pruning if statements. 2013-09-18 13:33:45 -04:00
Pete Hunt
a9d53dae72 Merge pull request #351 from spicyj/api-docs
Flesh out reference documentation, more API info
2013-09-17 16:12:16 -07:00
Tim Yung
ea0cde2cf4 Fix PropTypes Documentation 2013-09-17 16:09:23 -07:00
Sebastian Markbage
e5ba82a44b Fix DOM node warning
bdf2a9bb12 broke the warning that children aren't suppose to be real DOM nodes.
2013-09-17 16:04:44 -07:00
Ben Alpert
364d6029b6 Flesh out reference documentation, more API info 2013-09-17 16:01:57 -07:00
Pete Hunt
735223fc9f Merge pull request #356 from yungsters/master
Add link to third-party `JavaScript (JSX).tmLanguage` in docs.
2013-09-17 13:35:59 -07:00
yungsters
be9ac236fd Add link to third-party JavaScript (JSX).tmLanguage in docs. 2013-09-17 13:30:53 -07:00
Josh Duck
ed7fa0ed22 Stop ReactInputSelection breaking in IE8
In the IE code path the method assumed that the input.value property
was non-null. A quick fix is to use either value or innerText; which means
the same code can be shared for textarea and contentEditable components.

The code is slightly buggy because the range.parentElement() !== input check
will fail for contentEditable components when the focus within a deep DOM tree.
2013-09-14 06:18:03 -07:00
Tim Yung
3e4302e6ae Fix lint errors in tests 2013-09-14 06:17:50 -07:00
Josh Duck
1a38cb9e07 Ensure selection range exists
The selection object doesn't always have ranges. In Chrome the
selection is not updated before 'focus' event handlers are fired. See
http://jsfiddle.net/t4DYA/ for example.

The selection will have rangeCount of 0 and calling getRangeAt(0) will
throw error "Uncaught IndexSizeError: Index or size was negative, or greater
than the allowed value."
2013-09-14 06:16:15 -07:00
Paul O’Shannessy
71ad5cb37a Update wording 2013-09-14 13:48:17 +02:00
Paul O’Shannessy
8a7c977942 Merge pull request #338 from spicyj/fullpage-tests
Fix ReactRenderDocument tests
2013-09-11 16:54:48 -07:00
Paul O’Shannessy
63bacfacfd Merge pull request #339 from spicyj/doc-rendering
Fix full-page rendering
2013-09-11 16:54:31 -07:00
Paul O’Shannessy
c8ec4595bb Merge pull request #344 from benjamn/fix-silent-test-failure-due-to-requiring-React
Use a regular expression to parse out React.version
2013-09-11 16:03:59 -07:00
Ben Newman
133ea3df09 Use a regular expression to parse out React.version.
This fixes a silent failure of the test suite that appears to be due to
the call require('./build/modules/React').
2013-09-11 18:41:56 -04:00
Paul O’Shannessy
f729a28f3c Delete version.js
This file is an artifact of a build process long abandoned.
2013-09-11 14:20:26 -07:00
Paul O’Shannessy
7ff11c3c88 Merge pull request #332 from spicyj/radio-test
Fix radio input test in Chrome
2013-09-11 13:45:47 -07:00
Paul O’Shannessy
5ab68d9a0d Hard code version instead of doing constant replacement
This isn't really ideal, but it makes it so that people managing to
build with @providesModule still get a consistent experience (since this
is what gets packed client-side with react-page-middleware anyway).
2013-09-11 09:51:43 -07:00
Ben Alpert
58fae896fe Fix full-page rendering
Closes #337.

Test Plan:
Opened react-page sample without any JS errors. Also ran grunt test after cherry-picking this changeset on top of #338.
2013-09-11 01:26:49 -07:00
Ben Alpert
fea4fec0bc Fix ReactRenderDocument tests
I am unsure how this was ever supposed to work, as testDocument is guaranteed to be undefined at that point since beforeEach doesn't run synchronously. (I don't think there's any way to have beforeEach halt the tests.)
2013-09-10 22:42:05 -07:00
Paul O’Shannessy
d853bbcf77 Merge pull request #205 from spicyj/version
Add React.version
2013-09-10 18:35:12 -07:00
Paul O’Shannessy
f82f2a0fe2 Merge pull request #274 from chenglou/textarea-patch
fix textarea `value` of number 0
2013-09-10 18:01:33 -07:00
Ben Alpert
f69112cb3f JSX: Respect original spacing and newlines better
Fixes #335.

Now this JSX:

```
/** @jsx React.DOM */
var HelloMessage = React.createClass({
  render: function() {
    return <div>
      Look!
      <a href=
        "http://www.facebook.com/">Facebook
      </a>
    </div>;
  }
});
```

produces

```
/** @jsx React.DOM */
var HelloMessage = React.createClass({displayName: 'HelloMessage',
  render: function() {
    return React.DOM.div(null,
      " Look! ",
      React.DOM.a( {href:
        "http://www.facebook.com/"}, "Facebook "
      )
    );
  }
});
```

rather than the less-desirable

```
/** @jsx React.DOM */
var HelloMessage = React.createClass({displayName: 'HelloMessage',
  render: function() {
    return React.DOM.div(null,
" Look! ",      React.DOM.a( {href:"http://www.facebook.com/"}, "Facebook "      ),
    );
  }
});
```
2013-09-10 17:14:36 -07:00
Paul O’Shannessy
6d77ad4be3 Merge pull request #330 from spicyj/warn-class-for
Warn for 'class' and 'for' property names
2013-09-10 16:21:33 -07:00
Jeff Morrison
7a6a508066 Merge pull request #328 from zpao/no-transform-class
Stop transforming class -> className
2013-09-10 08:23:08 -07:00
Cheng Lou
cd019871e3 Fix input/textarea value of number 0 and false
Previously, setting textarea `value` to number 0 is treated as if `value` wasn't set at all (thus the textarea is cleared from 0 to '' upon `onChange`). `false` also renders as `"false"` instead of `""` for both `defaultValue` and `value`, on textarea _and_ input.
2013-09-10 10:40:53 -04:00
Paul O’Shannessy
63b58cf6b5 AUTHORS
Created a .mailmap file with all of the associations, then used
git + perl to create the AUTHORS file. In theory these should all get
picked up by npm.

I used ABC order so it would remain unbiased and automatable. I wish we
could go back and fill out the history or at least fix the commits we
have from CommitSyncScript, but oh well.

This also includes the script I used to automate this process in the
future.
2013-09-09 23:42:54 -07:00
Ben Alpert
3bbd966a82 Fix radio input test in Chrome
It seems like the `form="pluto"` was throwing it off and making the input live outside the form it should have been contained in, causing it to uncheck A. I added it intending to test the form attribute but ended up not needing it so removing it should be fine. (The tests were passing in phantomjs since it doesn't support the `form` attribute and simply ignored it.)

Test Plan:
grunt test; grunt test --debug
2013-09-09 23:38:05 -07:00
Isaac Salier-Hellendag
5388d70bb1 Add cut, copy, paste
Add clipboard events to React.

For forms, these shouldn't really be necessary -- the onChange event should handle deletions and insertions. For contenteditables, however, we need to be able to access clipboard data.
2013-09-09 23:33:05 -07:00
Ben Alpert
5fd4467bf7 Add React.version
getConfig needs to be a function because grunt.config.data.pkg.version isn't available at the time that grunt/config/jsx/jsx.js is required.

Test Plan:
grunt build, grunt lint, grunt test all work. After building, both react.js and react.min.js contain the version number.
2013-09-09 17:01:06 -07:00
Timothy Yung
aa765e8fa3 Merge pull request #287 from spicyj/noglobal
Remove all uses of ExecutionEnvironment.global
2013-09-09 16:23:20 -07:00
Ben Alpert
232b61044c Warn for 'class' and 'for' property names
Also stroke-linecap, stroke-width, stop-color, stop-opacity.

Test Plan:
grunt test
2013-09-09 15:59:42 -07:00
Ben Alpert
426cdbb3ae Remove all uses of ExecutionEnvironment.global
Closes #271.

All three of these files are DOM-specific so it should be fine to use window. (ReactEventTopLevelCallback isn't obviously DOM-specific but it calls getEventTarget which is so I think we're fine here.)

Test Plan:
grunt test, tried events in a real browser and they seemed to work still.
2013-09-09 15:51:06 -07:00
Paul O’Shannessy
d83fe785c5 Stop transforming class -> className
Update the broken examples too (`git grep class=`)
2013-09-09 15:37:43 -07:00
Ben Newman
888cc309e0 Stop using comments as boundary markers in dangerouslyRenderMarkup.
Jordan warned (and StackOverflow confirmed) that IE8 doesn't respect HTML
comment nodes when setting `.innerHTML`:
http://stackoverflow.com/questions/15006001/inserting-a-comment-in-innerhtml

The virtue of the comment strategy was that the parser did all the work of
maintaining the boundaries between markup chunks, using comments as the
boundary markers.  The new strategy (of tagging the first node with a
special attribute) has a similar virtue, since the parser should preserve
that attribute only for the nodes we care about, and any rendered nodes
that do not have the attribute can be ignored (and complained about by
`console.error`).
2013-09-09 14:59:55 -07:00
Paul O'Shannessy
4ed7b85ed8 Log unknown props only when we have a match
Logging every unknown property got very noisy when combined with use of `transferPropsTo`. I knew this would be a potential issue initially but decided it was worth it. Others disagreed and it's resulting in some confusion.

This changes the logging to ensure that we have a potential correction, so only DOMish properties should result in warnings.
2013-09-09 14:57:56 -07:00
Pete Hunt
647731e399 Supporting mounting into iframes
Sencha says that separating big components into their own iframes was important for performance:
http://www.sencha.com/blog/the-making-of-fastbook-an-html5-love-story.

Today the only thing stopping us is that events don't bubble to our events system from an iframe. This diff
looks at the owning document of the container and adds top-level listeners to it. It should not change
existing behavior and should improve our support for this.
2013-09-09 14:57:33 -07:00
Ben Newman
cd7d863f20 Avoid unnecessary array allocations in dangerouslyRenderMarkup. 2013-09-09 14:56:27 -07:00
Paul O'Shannessy
9d0f3623c3 Cache length of NodeList when updating radios 2013-09-09 11:53:13 -07:00
Pete Hunt
e010a2d90b Fix bugs with CSS3 animation event in webkit
We were incorrectly sniffing the animationend event.
2013-09-09 11:52:59 -07:00
Paul O’Shannessy
d704bc24f4 Initial build of ReactTransitionGroup
This builds `ReactTransitionGroup` with it's own copy of `React`, which
it total clownshoes. This should be technically usable, but definitely
should not be used in any production environment.
2013-09-07 16:18:14 -07:00
Paul O’Shannessy
ff2fc586d5 Merge pull request #324 from chenglou/backbone-todo-ex
Fix backbone todo example bugs.
2013-09-07 14:53:01 -07:00
Cheng Lou
78d305eb16 Fix backbone todo example bugs.
Fixed:
- New todo not submitting correctly (page refreshes. `preventDefault`
wasn't there.
- Old checked todo being removed will leave the checkmark on the next
todo replacing its position.
- Cannot change todo (`value`'s now a controlled field).
- `autofocus` (should be `autoFocus`, how ironic given the current
situation) on new todo input isn't working. Switched to manual
`focus()` in `componentDidMount` for now.
- More consistent breathing space between lines.
- Gutter at 80.

Added:
- Use todomvc-common base.css. The old one had to change ids to
classes. No longer necessary.
- Give `cx` a better name and move it in `Utils`.
- Trim input upon finishing edit.
- Remove todo if the new edited value is empty.
- Submit edited todo value on input blur.
- README to explain the existence of this example. Being able to
maintain a non-compilant version allows nice deviations from the
todomvc specs, such as animations, in the future.
2013-09-07 17:44:05 -04:00
Paul O’Shannessy
6b5c1810c0 Merge pull request #323 from benjamn/simplify-bin/jsx
Simplify bin/jsx to perform just the JSX transform
2013-09-07 14:41:55 -07:00
Paul O’Shannessy
e41912d6d4 Merge pull request #325 from spicyj/elseifdev
Move else if (__DEV__) into two statements
2013-09-07 14:08:03 -07:00
Ben Alpert
97e0926696 Move else if (__DEV__) into two statements
The minification stage doesn't like `else if (__DEV__)`.
2013-09-07 14:03:48 -07:00
Paul O’Shannessy
8df407deb8 Merge pull request #281 from spicyj/radio
Fix controlled radio button behavior
2013-09-07 13:54:57 -07:00
Paul O’Shannessy
2ba405d5f8 Merge pull request #267 from spicyj/warn-props
Warn about unknown property values
2013-09-07 13:06:41 -07:00
Ben Newman
658f41cb30 Simplify bin/jsx to perform just the JSX transform.
We will continue using `bin/jsx-internal`, well, internally.

Note that this version no longer respects `@providesModule`, and it
doesn't do anything special with constants like `__DEV__`, so we can no
longer get to claim that `bin/jsx` can be used to build the core.

I'm happy about this, personally, because it demonstrates the flexibility
of Commoner.
2013-09-06 16:20:25 -04:00
Ben Newman
ebc0d09595 Merge pull request #322 from petehunt/build-animations
Add ReactTransitionGroup to the build
2013-09-06 10:49:30 -07:00
petehunt
f7ea031dac Add ReactTransitionGroup to the build 2013-09-06 10:47:18 -07:00
Ben Alpert
b56b5885d0 Fix controlled radio button behavior
Fixes #242.
2013-09-06 00:57:51 -07:00
Ben Alpert
a4c23d328c Warn about unknown property values
Fixes #255.
2013-09-06 00:33:01 -07:00
Paul O'Shannessy
3cf14e8f9b Remove ReactChildren methods from React object
These are not terribly useful on this object and the naming of
`React.forEachChildren` sucked anyway.
2013-09-05 18:35:59 -07:00
Pete Hunt
c8886a0424 Make mounting on the root of the page work correctly
This was apparently only partially supported. We had issues initially mounting if there was no HTML present and
also had issues if we had to update HTML that was already there. This diff fixes all of these cases and has
tests to prove it. NOTE: I removed a test that was actually erroneous. My bad.
2013-09-05 13:50:18 -07:00
Paul O’Shannessy
4f0dea3e7e Merge pull request #294 from clayallsopp/better_update_msg
More helpful message if you update an unrendered component
2013-09-05 11:54:07 -07:00
Clay Allsopp
9dd8ef4777 fix formatting and test for correct error 2013-09-04 18:13:33 -07:00
Paul O’Shannessy
65c4ef91c7 Sync CSSCore from upstream 2013-09-04 16:47:16 -07:00
Pete Hunt
32d3d7774a Use dumpCache() rather than manual reset
I forgot this module existed until @benjamn reminded we had a way to do it.
2013-09-04 15:54:27 -07:00
Pete Hunt
8664c8ac57 Test cases covering rendering onto document
There were some bug reports here, I couldn't reproduce but wrote tests anyway. We should definitely have these.
2013-09-04 15:54:11 -07:00
Ben Newman
dea0cc01cf Improve error behavior of Danger.dangerouslyRenderMarkup.
HTML comment nodes are now interspersed in the original markup list so
that we can tell which chunks of markup rendered as more or less than one
node, and give a more helpful error message in that case.

Regardless of how many nodes were rendered, we only take the first one. If
zero nodes were rendered, then `resultList` will contain `null` at the
corresponding position.

If we decide to revisit the idea of using document fragments, it will be
very easy to handle the `!== 1` case by returning a document fragment.
2013-09-04 15:54:09 -07:00
Pete Hunt
80f1590265 Add ReactTransitionGroup
This introduces <ReactTransitionGroup>, a component that works a lot
like Angular's ng-animate.

The problem we're currently facing is twofold:
1. We don't really have a great convention surrounding CSS transitions
   in React
2. (harder) we can't animate nodes that are leaving the DOM, as their
   nodes are instantly destroyed.

To solve the first issue I've adopted Angular's convention. It's
implemented in ReactTransitionableChild.

The second part is what's tricky. To do this I've implemented three modules:
- ReactTransitionableChild, which can keep its old children around if they
  change to null
- ReactTransitionKeySet, which can look at a prev and next set of child
  keys and merge them in a reasonable way
- ReactTransitionGroup, which combines ReactTransitionableChild and
  ReactTransitionKeySet to keep nodes that are leaving the DOM in the
  DOM until their animations are complete
2013-09-04 15:54:06 -07:00
Paul O’Shannessy
c25c5b543b Update wording 2013-09-04 15:26:31 -07:00
Cheng Lou
8852b86ad8 Add Stack Overflow link for doc support page. 2013-09-04 16:01:48 -04:00
Paul O'Shannessy
a42fd30fc2 Remove React.autoBind for real
This has been deprecated for a long while now, we should actually remove it.
2013-09-03 14:27:00 -07:00
Pete Hunt
406dcbd8da Fix a few GC leaks in events system
Summary:
    - Weren't pooling the Transaction in the batching strategy
    - Creating a new closure for every event tick due to batchedUpdates()
    - EnterLeaveEventPlugin creates a new array on each event.

I wonder if there is more optimization opportunity in accumulate(). Squinting at the fps graph this seems to be faster and waste less memory but it's hard to conclusively tell. I did verify that these were all hotspots though.
2013-09-03 14:27:00 -07:00
Paul O’Shannessy
de61f9fd81 Merge pull request #298 from vjeux/pagination
Add pagination to blog
2013-09-03 13:35:12 -07:00
Paul O’Shannessy
57fe412619 Merge pull request #305 from brianr/tutorial-explain-showdown
Tutorial: show how to add showdown.js
2013-09-03 13:33:05 -07:00
Pete Hunt
b4ff29ac78 Merge pull request #312 from zpao/docs-redirect
Redirect /docs to the right page
2013-09-03 13:30:16 -07:00
Paul O’Shannessy
ba460de7ed Redirect /docs to the right page
I've hit this a few times where I want to get to docs so I take whatever
my urlbar gives me and strip out the actual page so I can get to the
root, however that's a 404.

This introduces a super easy way to redirect, which could be handy in
the future as docs get rewritten.

I would much rather do this with a real htaccess file or even just
handle 404s gracefully, but that's not currently an option with GitHub
pages (since we generate our own and don't use a custom domain).
2013-09-03 13:25:23 -07:00
Pete Hunt
c7768fde5d Merge pull request #307 from chenglou/todomvc-director
sync with tastejs todomvc
2013-09-02 10:22:58 -07:00
Clay Allsopp
15f84a391d move lifecycle check into replaceProps instead of updateComponent 2013-09-01 18:42:01 -07:00
Cheng Lou
2b9c34b5c7 sync with tastejs todomvc 2013-08-31 21:54:37 -04:00
Brian Rue
403b087e97 Tutorial: show how to add showdown.js 2013-08-30 16:29:01 -07:00
Sebastian Markbage
75aee1714b Expose the instance cache
We need access to the instance cache for debugging tools. Ideally we want to
expose a more stable and supported interface but this seems like a quick win,
for now.
2013-08-30 13:21:04 -07:00
Pete Hunt
c41e86c990 Make ReactDefaultPerf work server-side
We were reading from window which was throwing when ReactDefaultPerf was injected.
2013-08-30 13:20:53 -07:00
Paul O'Shannessy
4d8f0449d9 React.isValidClass
Sometimes you may need to detect if a value is a valid React class constructor. This enables that and prevents future consumers from getting caught in the trap of depending on an internal implementation detail we might change.

Currently this works for classes created with `React.createClass` as well as `React.DOM.*`.
2013-08-30 13:20:51 -07:00
Pete Hunt
0db4077c3a Make React batching strategy injectable 2013-08-30 13:20:48 -07:00
Tim Yung
f88aa35187 Change vendored module isDOMNode -> isNode 2013-08-30 13:20:45 -07:00
Andrew Zich
7d34c09e17 Don't trigger mouse events on native button elements that are disabled
This adds a `ReactDOMButton` module that shims the native `<button>` React component so it doesn't receive mouseup, mousemove, mousedown, click, or double-click events when its disabled property is truthy.
2013-08-30 13:20:40 -07:00
Paul O’Shannessy
e11c4ecbaf [docs] Small tweaks as reported in comments
* highlight `</form>`
* use correct id in `getElementById` call
2013-08-28 14:42:07 -07:00
Paul O’Shannessy
553ed1416c Update package dependencies
Sometimes I look at https://david-dm.org/facebook/react
2013-08-27 14:46:06 -07:00
Paul O’Shannessy
688f5051e6 Sync objMap from upstream 2013-08-27 14:43:46 -07:00
Pete Hunt
adb666e67f Allow getInitialState() for mixins
Today mixins can't easily be stateful because they can't provide getInitialState(). This allows multiple getInitialState() methods as long as they don't return objects that have conflicting keys. In that case, we throw.
2013-08-27 14:17:26 -07:00
Paul O’Shannessy
07e2072692 Support props for <meta> elements.
`content`, `httpEquiv`, `charSet` are all needed. We're currently
working around this in `react-page`.

`content` is the risky one here since we previously supporting using
`content` to set the text content. We removed support for that in
e998041229 so the risk is minimal, there
just might be some lingering old code.

Fixes #292

Test Plan: Visit `data:text/html,<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" charset="utf-8"></head>`

```
var m = document.querySelector('meta');
m.httpEquiv; // Content-Type
m.httpEquiv = 'foo';
m.httpEquiv; // foo

m.charset; // undefined
m.charSet; // undefined
m.getAttribute('charset'); // utf-8
m.setAttribute('charset', 'bar');
m.getAttribute('charset'); // bar

m.content; // text/html; charset=utf-8
m.content = 'baz';
m.content; // baz
```
2013-08-27 11:45:59 -07:00
Vjeux
1c14cd6c8b Add pagination to blog
- Add pagination
- Display full content in /blog
- Truncate Recent posts
- Add permalink that lists all the blog posts
- Add spacing and bullet around recent posts to make it more readable
2013-08-27 02:14:17 +02:00
Paul O’Shannessy
744b54a829 Fix capitalization of Tooling Integration page 2013-08-26 14:53:56 -07:00
Vjeux
a90c463abe Update the tooling page to include pyReact, react-rails and react-page 2013-08-26 14:49:31 -07:00
Vjeux
6bf21f1610 Community round-up #7
http://fooo.fr:4000/react/blog/2013/08/26/community-roundup-7.html
2013-08-26 14:22:16 -07:00
Ben Alpert
364ee1ffae Add missing "use strict" statement to pass lint
Test Plan:
grunt lint; grunt test
2013-08-26 13:46:11 -07:00
Clay Allsopp
88faef3ba9 Add more helpful invariant if you're updating an unrendered component 2013-08-26 10:42:53 -07:00
Eric Clemmons
bcc6b524fb Add rowSpan DOM property 2013-08-25 13:32:38 -05:00
Sebastian Markbage
61b38b9f05 Explicit and Implicit Keys Need Separate Namespaces
There are certain cases where you can end up with a collision with an implicit
key (array index) if your explicit key prop is a number. They should use
different namespaces. Therefore I wrap explicit keys in curlies and implicit
array indices in brackets.

I added a simple test case, but another case came up on the mailing list. Where
undefined entries in an array actually results in an entry and therefore an
implicit key.
2013-08-23 14:05:18 -07:00
Danny Ben-David
fce57abeca Benchmarking tool for React application performance
ReactAppPerf wraps core methods and logs info from them; there's no real
UI at this point
2013-08-23 14:05:11 -07:00
Paul O’Shannessy
946e9b0c80 Merge pull request #289 from jordwalke/ServerRenderingFixes3
Server rendering: rendering of entire document using React.
2013-08-23 13:14:06 -07:00
Jordan Walke
748ed6cd81 adding better test - moving execution env module. 2013-08-23 12:32:35 -07:00
Jordan Walke
49f174cdad Server rendering: rendering of entire document using React.
Summary: Allows rendering of React into the "document" as opposed to into a
particular node. To recap some basics:

document: One level above the <html> tag - like the browser.
document.documentElement: <body>

To support full-page server side rendering, we need to be able to render
*everything* including the HTML/BODY tags. This allows that.
2013-08-23 02:04:07 -07:00
Paul O’Shannessy
6ca8d31c83 [react-tools] Add src/ to files
This is so it's possible to use the original @providesModule source
files in a toolchain that understands those.
2013-08-22 22:35:50 -07:00
Paul O’Shannessy
aa1fa7468b Merge pull request #280 from jeffmo/jstransform_npm
Move to using `jstransform` and `esprima-fb` npm modules
2013-08-22 15:43:59 -07:00
JeffMo
2d048f1f34 Move to using jstransform and esprima-fb npm modules 2013-08-22 15:28:41 -07:00
Clay Allsopp
3d1cc16a9b Add CDNJS to docs. Fixes #244 2013-08-22 11:07:50 -07:00
Paul O’Shannessy
cbe86e04b3 Docs: fix header 2013-08-22 11:02:09 -07:00
Paul O’Shannessy
a558e560bd Use script to find remaining 404s. Fix them. 2013-08-22 10:59:22 -07:00
Clay Allsopp
cfe4152b1d Fix broken tutorial link and change wording 2013-08-21 22:38:44 -07:00
Kunal Mehta
91c2a8d90b Added PyReact blog post. 2013-08-19 14:48:28 -07:00
Christopher Chedeau
2c8f907b2c Merge pull request #277 from stoyan/patch-1
typo fix
2013-08-19 11:45:51 -07:00
Tim Yung
669f4b867f Allow DOM Nodes in ImmutableObject
Currently, `ImmutableObject` will stack overflow while it tries to recurse and deep freeze all the properties of a DOM node.
2013-08-19 11:37:08 -07:00
Stoyan
5fae286cf4 typo fix 2013-08-19 11:35:46 -07:00
Timothy Yung
a2c90aad86 Merge pull request #275 from spicyj/input-private
Make getChecked, getValue, handleChange private
2013-08-19 11:20:52 -07:00
Ben Alpert
898621d0a1 Make getChecked, getValue, handleChange private
Test Plan: grunt test, enter text in ballmer-peak example without any JS errors.
2013-08-17 22:29:41 -07:00
Timothy Yung
e1c1d869de Merge pull request #251 from spicyj/select-value
Fix behavior of ReactDOMSelect with `defaultValue`
2013-08-17 21:50:13 -07:00
Ben Alpert
25e2cd0db6 Fix behavior of ReactDOMSelect
Closes #250.

Test Plan:
With multiple and not, verified: With defaultValue, the correct option is picked initially, user changes change the selection, and changes to defaultValue have no effect. With value, the correct option is picked initially, user changes do nothing, and changes to value change the selection.

Also ran the tests.
2013-08-17 16:57:49 -07:00
Paul O’Shannessy
1f8ef4c903 Sync modules to vendor/core
We haven't done this recently. Nothing has changed significantly, though
this does remove some files we weren't using.
2013-08-16 15:40:23 -07:00
James Ide
d9511d817a Move utils out of React that aren't being used
Many of React's util functions are non-redundant with Facebook's core
libraries, so move them out of React into a central location (out of
this repo).

These files were not getting used by any part of React core, so didn't
actually belong here anyway.
2013-08-16 15:40:11 -07:00
Cheng Lou
2fda70fb4a fix test case for rendering text node number 0 2013-08-16 13:51:17 -07:00
Sebastian Markbåge
02f618d52c Merge pull request #268 from spicyj/bind-null
Make .bind(null, ...) work on autobound methods
2013-08-16 12:06:49 -07:00
Jordan Walke
61c47e4cae Refactor ReactComponent to have no dependency on the DOM.
React is more than just a DOM app library, it is a component
abstraction library. This enforces that.
2013-08-15 10:56:39 -07:00
Jordan Walke
e6b216bdbb Extract out core ReactEmitter functionality.
Other environments can make use of some of the logic in ReactEventEmitter.
2013-08-15 10:56:30 -07:00
Ben Alpert
192727e152 Make .bind(null, ...) work on autobound methods
Fixes #266.
2013-08-15 09:58:38 -07:00
Paul O’Shannessy
cb00d3e66c Upgrade phantomjs to 1.9.1-4
This fixes the install and permissions issues we've been seeing with
other 1.9.1-x versions.
2013-08-13 15:37:26 -07:00
Paul O’Shannessy
987e5e8f13 Merge pull request #258 from chenglou/patch-3
defaultValue of 0 now displayed
2013-08-12 18:20:32 -07:00
Paul O’Shannessy
df0bc8c3af Merge pull request #261 from benjamn/phantomjs-1.9.0-1
Hold PhantomJS version at 1.9.0-1.
2013-08-12 15:21:50 -07:00
Ben Newman
983120102c Hold PhantomJS version at 1.9.0-1.
And don't attempt any chmod magic, either.
2013-08-12 17:47:31 -04:00
Cheng Lou
86c0b69390 separate new tests into respective file 2013-08-12 17:03:10 -04:00
Cheng Lou
d5989a0de4 tests for displaying defaultValue of 0 2013-08-12 16:08:16 -04:00
Cheng Lou
1b747c526c defaultValue of 0 now displayed
previously treated as empty string when passed to input text/textarea
2013-08-09 23:13:44 -04:00
Paul O'Shannessy
5cbabdf4c9 Support autocapitalize DOM Property
It's non-standard, but potentially useful on mobile.

See some discussion in google group: https://groups.google.com/forum/#!topic/reactjs/MBcCFohHHHA

Closes #247
2013-08-06 14:19:49 -07:00
Paul Shen
9ef4e74ba2 ReactChildren
Instead of changing `traverseAllChildren`, keep that around for perf
reasons (for the hot code path `flattenChildren`)

Introduce `ReactChildren.map` and `ReactChildren.forEach`
which mirrors `Array.prototype.map` and `Array.prototype.forEach`. This
involves a rename of `mapAllChildren`
2013-08-06 14:17:33 -07:00
Vjeux
0321171113 Community Round-up #6 2013-08-06 01:31:23 +02:00
Christopher Chedeau
d542621155 Fix 404 in Getting Started 2013-08-04 21:09:15 -07:00
Pete Hunt
4bbf8acc9b Merge pull request #249 from pcottle/fixLinks
Fix Github links in examples
2013-08-04 17:40:00 -07:00
Peter Cottle
a21556314d Fix Github links in examples
Looks like we link to github.com/facebook/react/ instead of react-js. This just fixes the links

`grep -r "facebook/react.js" .` comes up clean now
2013-08-04 16:40:12 -07:00
Paul O'Shannessy
99d3d7f914 Get rid of remaining ReactID references
It's gone. Also compacted a bit of code to match the other usage.
2013-08-01 13:58:28 -07:00
Paul O’Shannessy
86d9e0a97a Merge pull request #245 from chenglou/patch-3
Change ref from ReactID to ReactInstanceHandles
2013-08-01 13:41:10 -07:00
Cheng Lou
db0ff96200 Change ref from ReactID to ReactInstanceHandles 2013-08-01 14:52:08 -04:00
Tim Yung
808e625d9d Use createNodesFromMarkup
Pulled out markup rendering logic for better reuse.
2013-07-31 21:21:06 -07:00
Paul O’Shannessy
dc06704ec7 react-rails blog post 2013-07-30 15:25:44 -07:00
Tim Yung
5ef3c1b09b Fix Reconciling Components to Content
This fixes a reconciliation bug introduced by adffa9b0f4.

The new unit test case exhibits the bug. When a component that has rendered child components is updated to render inline text, we usually:

 # Unmount and remove all child components.
 # Set the new inline text content.

However, with batched child operations, we do not **remove all child components** until later. The current implementation will set the inline text content and blow away those nodes, causing a fatal when `ReactMultiChild` later tries to find and remove those nodes.

This fixes the bug by ensuring that text content changes are also enqueued.
2013-07-29 16:15:30 -07:00
Paul O’Shannessy
fe451c30f8 Merge pull request #241 from gasi/master
Fix incorrect port of standard Python server
2013-07-29 11:09:37 -07:00
Daniel Gasienica
6f2848f4a6 Fix incorrect port of standard Python server
/ht @zpao
2013-07-29 10:59:43 -07:00
Paul O’Shannessy
d63ce62916 Merge pull request #207 from thisishugo/patch-1
update dead jsx link to point to an extant page
2013-07-29 09:11:37 -07:00
Ben Newman
c7d6a5ae4d Merge pull request #237 from yungsters/master
Fix Test Failures
2013-07-28 07:02:17 -07:00
yungsters
d5e970b93f Fix Danger test failures.
The original tests were flawed because the `Danger` module exploits the fact that all React-generated markup has at least one attribute. This allows the module to extract node names from markup strings faster.

However, the tests were passing in strings of markup with no attributes.

Also, this fixes a test failure due to the test trying to set text content into a `<tr>` which is typically disallowed by browsers (and PhantomJS). This changes it to use `<td>` instead.
2013-07-28 01:05:13 -07:00
yungsters
4cb49f5561 Change ReactMultiChild test to check for innerHTML descriptor.
Not all testing environments will support setting the `innerHTML` descriptor. For example, PhantomJS initializes the `innerHTML` property as not configurable.
2013-07-28 01:04:24 -07:00
Paul O’Shannessy
c347b720a9 Updated Readme for 0.4.1 2013-07-26 15:57:37 -07:00
Paul O’Shannessy
27a1729f6d Blog post for v0.4.1 2013-07-26 15:56:52 -07:00
Paul O’Shannessy
a1f5c1dee7 Updated Changelog for 0.4.1 2013-07-26 15:56:22 -07:00
Paul O’Shannessy
20179b7991 Send branch info from travis for continuous builds 2013-07-26 14:28:33 -07:00
Tim Yung
adffa9b0f4 Batch Child Markup Generation
Setting `innerHTML` is slow: http://jsperf.com/react-child-creation/2

This reduces the number of times we set `innerHTML` by batching markup generation in a component tree.

As usual, I cleaned up the `ReactMultiChild` module significantly.

== Children Reconciliation ==

When a `ReactNativeComponent` reconciles, it compares currently rendered children, `prevChildren`, with the new children, `nextChildren`. It figures out the shortest series of updates required to render `nextChildren` where each update is one of:

 - Create nodes for a new child and insert it at an index.
 - Update an existing node and, if necessary, move it to an index.
 - Remove an existing node.

This serializable series of updates is sent to `ReactDOMIDOperations` where the actions are actually acted on.

== Problem ==

There are two problems:

 # When a `ReactNativeComponent` renders new children, it sets `innerHTML` once for each contiguous set of children.
 # Each `ReactNativeComponent` renders its children in isolation, so two components that both render new children will do so separately.

For example, consider the following update:

  React.renderComponent(<div><p><span /></p><p><span /></p></div>, ...);
  React.renderComponent(<div><p><img /><span /><img /></p><p><img /><span /><img /></p></div>, ...);

This will trigger setting `innerHTML` four times.

== Solution ==

Instead of enqueuing the series of updates per component, this diff changes `ReactMultiChild` to enqueue updates per component tree (which works by counting recursive calls to `updateChildren`). Once all updates in the tree are accounted for, we render all markup using a single `innerHTML` set.
2013-07-26 12:48:07 -07:00
Tim Yung
2e37f65bdc Delete throwIf
Deletes `throwIf()` in favor of having one way to throw errors: `invariant()`
2013-07-26 12:48:07 -07:00
Hugo Jobling
4ab62a6bd2 remove dead link
the event handling doc page no longer exists
2013-07-18 11:05:39 +01:00
Hugo Jobling
07427ae9d0 put closing paren in correct place 2013-07-18 10:44:22 +01:00
Hugo Jobling
8f55d94d40 update dead jsx link to point to an extant page
syntax.html no longer exists, so point people at the in depth article instead.
2013-07-18 10:36:54 +01:00
523 changed files with 29049 additions and 12041 deletions

View File

@@ -2,11 +2,13 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
max_line_length = 80
trim_trailing_whitespace = true
[*.md]
max_line_length = 0
trim_trailing_whitespace = false

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
* text=auto

12
.gitignore vendored
View File

@@ -13,13 +13,9 @@ docs/code
docs/_site
docs/.sass-cache
docs/css/react.css
docs/js/.module-cache
docs/js/JSXTransformer.js
docs/js/react.min.js
docs/js/docs.js
docs/js/jsx-compiler.js
docs/js/live_editor.js
docs/js/examples
docs/js/*
docs/downloads
examples/shared/*.js
test/the-files-to-test.generated.js
*.log*
chrome-user-data

View File

@@ -13,6 +13,7 @@
"noempty": true,
"nonstandard": true,
"onecase": true,
"sub": true,
"regexdash": true,
"trailing": true,
"undef": true,

42
.mailmap Normal file
View File

@@ -0,0 +1,42 @@
Ben Newman <bn@cs.stanford.edu> <benjamn@fb.com>
Cheng Lou <chenglou92@gmail.com> <chenglou@fb.com>
Christoph Pojer <christoph.pojer@gmail.com>
Christoph Pojer <christoph.pojer@gmail.com> <cpojer@fb.com>
Connor McSheffrey <c@conr.me> <connor.mcsheffrey@gmail.com>
Dan Schafer <dschafer@fb.com>
Fabio M. Costa <fabiomcosta@gmail.com> <fabs@fb.com>
Harry Hull <harry.hull1@gmail.com>
Ingvar Stepanyan <me@rreverser.com> <rreverser@ubuntu.rreverser.a4.internal.cloudapp.net>
Jason Bonta <jbonta@gmail.com> <jasonbonta@fb.com>
Jason Trill <jason@jasontrill.com>
Jeff Morrison <jeff@anafx.com> <Jeff@anafx.com>
Jeff Morrison <jeff@anafx.com> <jeffmo@fb.com>
Jeffrey Lin <lin.jeffrey@gmail.com> <jeffreylin@fb.com>
Jonathan Hsu <jhiswin@gmail.com>
Jordan Walke <jordojw@gmail.com>
Jordan Walke <jordojw@gmail.com> <jordanjcw@fb.com>
Josh Duck <josh@fb.com> <github@joshduck.com>
Jun Wu <quark@lihdd.net>
Keito Uchiyama <projects@keito.me> <keito@fb.com>
Laurence Rowe <l@lrowe.co.uk> <laurence@lrowe.co.uk>
Martin Andert <mandert@gmail.com>
Michal Srb <xixixao@seznam.cz> xixixao <xixixao@seznam.cz>
Nick Gavalas <njg57@cornell.edu>
Nick Thompson <ncthom91@gmail.com> <nickt@instagram.com>
Paul OShannessy <paul@oshannessy.com> <poshannessy@fb.com>
Paul Shen <paul@mnml0.com> <paulshen@fb.com>
Pete Hunt <floydophone@gmail.com>
Pete Hunt <floydophone@gmail.com> <pete.hunt@fb.com>
Pete Hunt <floydophone@gmail.com> <pete@instagram.com>
Pete Hunt <floydophone@gmail.com> <phunt@instagram.com>
Petri Lievonen <plievone@cc.hut.fi>
Pieter Vanderwerff <me@pieter.io> <pieter@heyday.co.nz>
Richard Feldman <richard.t.feldman@gmail.com> <richard@noredink.com>
Richard Livesey <Livesey7@hotmail.co.uk>
Sander Spies <sandermail@gmail.com>
Sebastian Markbåge <sebastian@calyptus.eu> <sema@fb.com>
Stoyan Stefanov <ssttoo@ymail.com>
Thomas Aylott <oblivious@subtlegradient.com> <aylott@fb.com>
Timothy Yung <yungsters@gmail.com> <yungsters@fb.com>
Vjeux <vjeuxx@gmail.com>
Vjeux <vjeuxx@gmail.com> <vjeux@fb.com>

View File

@@ -2,13 +2,62 @@
language: node_js
node_js:
- '0.10'
script:
- |
grunt $TEST_TYPE
after_script:
- curl -F "react=@build/react.js" -F "react.min=@build/react.min.js" -F "transformer=@build/JSXTransformer.js"
-F "commit=$TRAVIS_COMMIT" -F "date=`git log --format='%ct' -1`" -F "pull_request=$TRAVIS_PULL_REQUEST"
-F "token=$SECRET_TOKEN" -F "branch=$TRAVIS_BRANCH" $SERVER
- |
if [ "$TEST_TYPE" = test:full ] && [ "$SERVER" ]; then
grunt build
curl \
-F "react=@build/react.js" \
-F "react.min=@build/react.min.js" \
-F "transformer=@build/JSXTransformer.js" \
-F "react-with-addons=@build/react-with-addons.js" \
-F "react-with-addons.min=@build/react-with-addons.min.js" \
-F "npm-react=@build/react.tgz" \
-F "npm-react-tools=@build/react-tools.tgz" \
-F "commit=$TRAVIS_COMMIT" \
-F "date=`git log --format='%ct' -1`" \
-F "pull_request=$TRAVIS_PULL_REQUEST" \
-F "token=$SECRET_TOKEN" \
-F "branch=$TRAVIS_BRANCH" \
$SERVER
fi
env:
matrix:
- TEST_TYPE=test:full
- TEST_TYPE=lint
- TEST_TYPE=perf:full
- TEST_TYPE=test:coverage
- TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie11
- TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie10
- TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie9
- TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie8
- TEST_TYPE=test:webdriver:saucelabs:ios
- TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=safari
global:
# SERVER
- secure: qPvsJ46XzGrdIuPA70b55xQNGF8jcK7N1LN5CCQYYocXLa+fBrl+fTE77QvehOPhqwJXcj6kOxI+sY0KrVwV7gmq2XY2HZGWUSCxTN0SZlNIzqPA80Y7G/yOjA4PUt8LKgP+8tptyhTAY56qf+hgW8BoLiKOdztYF2p+3zXOLuA=
# SECRET_TOKEN
- secure: dkpPW+VnoqC/okhRdV90m36NcyBFhcwEKL3bNFExAwi0dXnFao8RoFlvnwiPlA23h2faROkMIetXlti6Aju08BgUFV+f9aL6vLyU7gUent4Nd3413zf2fwDtXIWIETg6uLnOpSykGKgCAT/hY3Q2oPLqOoY0OxfgnbqwxkxljrE=
matrix:
fast_finish: true
allow_failures:
- env: TEST_TYPE=lint
- env: TEST_TYPE=test:coverage
- env: TEST_TYPE=perf:full
- env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie11
- env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie10
- env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie9
- env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=ie8
- env: TEST_TYPE=test:webdriver:saucelabs:ios
- env: TEST_TYPE=test:webdriver:saucelabs BROWSER_NAME=safari
notifications:
irc:
use_notice: true
skip_join: true
on_success: change
on_failure: change
channels:
- chat.freenode.net#reactjs

109
AUTHORS Normal file
View File

@@ -0,0 +1,109 @@
Alan deLevie <adelevie@gmail.com>
Alex Zelenskiy <azelenskiy@fb.com>
Alexander Solovyov <alexander@solovyov.net>
Andreas Svensson <andreas@syranide.com>
Andrew Davey <andrew@equin.co.uk>
Andrew Zich <azich@fb.com>
Andrey Popp <8mayday@gmail.com>
Ayman Osman <aymano.osman@gmail.com>
Ben Alpert <spicyjalapeno@gmail.com>
Ben Newman <bn@cs.stanford.edu>
Ben Ripkens <bripkens.dev@gmail.com>
Bob Eagan <bob@synapsestudios.com>
Brian Cooke <bri@bricooke.com>
Brian Kim <briankimpossible@gmail.com>
Brian Rue <brian@rollbar.com>
Cam Spiers <camspiers@gmail.com>
Cat Chen <catchen@fb.com>
Cheng Lou <chenglou92@gmail.com>
Christian Roman <chroman16@gmail.com>
Christoph Pojer <christoph.pojer@gmail.com>
Clay Allsopp <clay.allsopp@gmail.com>
Connor McSheffrey <c@conr.me>
Dan Schafer <dschafer@fb.com>
Daniel Gasienica <dgasienica@zynga.com>
Daniel Lo Nigro <danlo@fb.com>
Daniel Miladinov <dmiladinov@wingspan.com>
Danny Ben-David <dannybd@fb.com>
David Hellsing <david@aino.se>
David Hu <davidhu91@gmail.com>
Dustin Getz <dgetz@wingspan.com>
Eric Clemmons <eric@smarterspam.com>
Eric Schoffstall <contra@wearefractal.com>
Fabio M. Costa <fabiomcosta@gmail.com>
Felipe Oliveira Carvalho <felipekde@gmail.com>
Felix Kling <fkling@fb.com>
Fernando Correia <fernando@servicero.com>
Greg Roodt <groodt@gmail.com>
Guido Bouman <m@guido.vc>
Harry Hull <harry.hull1@gmail.com>
Hugo Jobling <me@thisishugo.com>
Ian Obermiller <iano@fb.com>
Ingvar Stepanyan <me@rreverser.com>
Isaac Salier-Hellendag <isaac@fb.com>
Ivan Kozik <ivan@ludios.org>
Jakub Malinowski <jakubmal@gmail.com>
James Ide <ide@fb.com>
Jamie Wong <jamie.lf.wong@gmail.com>
Jamison Dance <jergason@gmail.com>
Jan Kassens <jkassens@fb.com>
Jared Forsyth <jared@jaredforsyth.com>
Jason Bonta <jbonta@gmail.com>
Jason Trill <jason@jasontrill.com>
Jean Lauliac <lauliacj@gmail.com>
Jeff Morrison <jeff@anafx.com>
Jeffrey Lin <lin.jeffrey@gmail.com>
Jignesh Kakadiya <jigneshhk1992@gmail.com>
Johannes Baiter <johannes.baiter@gmail.com>
John Watson <jwatson@fb.com>
Jonas Gebhardt <jonas@instagram.com>
Jonathan Hsu <jhiswin@gmail.com>
Jordan Walke <jordojw@gmail.com>
Josh Duck <josh@fb.com>
Jun Wu <quark@lihdd.net>
Keito Uchiyama <projects@keito.me>
Kit Randel <kit@nocturne.net.nz>
Kunal Mehta <k.mehta@berkeley.edu>
Laurence Rowe <l@lrowe.co.uk>
Levi McCallum <levi@levimccallum.com>
Logan Allen <loganfynne@gmail.com>
Luigy Leon <luichi.19@gmail.com>
Mark Richardson <echo@fb.com>
Marshall Roch <mroch@fb.com>
Martin Andert <mandert@gmail.com>
Martin Konicek <mkonicek@fb.com>
Mathieu M-Gosselin <mathieumg@gmail.com>
Matt Harrison <mt.harrison86@gmail.com>
Matti Nelimarkka <matti.nelimarkka@hiit.fi>
Michal Srb <xixixao@seznam.cz>
Mouad Debbar <mdebbar@fb.com>
Nadeesha Cabral <nadeesha.cabral@gmail.com>
Nicholas Bergson-Shilcock <me@nicholasbs.net>
Nick Gavalas <njg57@cornell.edu>
Nick Thompson <ncthom91@gmail.com>
Owen Coutts <owenc@fb.com>
Pascal Hartig <passy@twitter.com>
Paul OShannessy <paul@oshannessy.com>
Paul Seiffert <paul.seiffert@gmail.com>
Paul Shen <paul@mnml0.com>
Pete Hunt <floydophone@gmail.com>
Peter Cottle <pcottle@fb.com>
Petri Lievonen <plievone@cc.hut.fi>
Pieter Vanderwerff <me@pieter.io>
Richard D. Worth <rdworth@gmail.com>
Richard Feldman <richard.t.feldman@gmail.com>
Richard Livesey <Livesey7@hotmail.co.uk>
Sander Spies <sandermail@gmail.com>
Sean Kinsey <oyvind@fb.com>
Sebastian Markbåge <sebastian@calyptus.eu>
Shaun Trennery <shaun.trennery@gmail.com>
Simon Højberg <r.hackr@gmail.com>
Stoyan Stefanov <ssttoo@ymail.com>
Sundeep Malladi <sundeep.malladi@gmail.com>
Thomas Aylott <oblivious@subtlegradient.com>
Timothy Yung <yungsters@gmail.com>
Tom Occhino <tomocchino@gmail.com>
Vjeux <vjeuxx@gmail.com>
Wincent Colaiuta <win@wincent.com>
Zach Bruggeman <zbruggeman@me.com>
imagentleman <imagentlemail@gmail.com>

View File

@@ -1,3 +1,169 @@
## 0.9.0 (February 20, 2014)
### React Core
#### Breaking Changes
- The lifecycle methods `componentDidMount` and `componentDidUpdate` no longer receive the root node as a parameter; use `this.getDOMNode()` instead
- Whenever a prop is equal to `undefined`, the default value returned by `getDefaultProps` will now be used instead
- `React.unmountAndReleaseReactRootNode` was previously deprecated and has now been removed
- `React.renderComponentToString` is now synchronous and returns the generated HTML string
- Full-page rendering (that is, rendering the `<html>` tag using React) is now supported only when starting with server-rendered markup
- On mouse wheel events, `deltaY` is no longer negated
- When prop types validation fails, a warning is logged instead of an error thrown (with the production build of React, type checks are now skipped for performance)
- On `input`, `select`, and `textarea` elements, `.getValue()` is no longer supported; use `.getDOMNode().value` instead
- `this.context` on components is now reserved for internal use by React
#### New Features
- React now never rethrows errors, so stack traces are more accurate and Chrome's purple break-on-error stop sign now works properly
- Added support for SVG tags `defs`, `linearGradient`, `polygon`, `radialGradient`, `stop`
- Added support for more attributes:
- `crossOrigin` for CORS requests
- `download` and `hrefLang` for `<a>` tags
- `mediaGroup` and `muted` for `<audio>` and `<video>` tags
- `noValidate` and `formNoValidate` for forms
- `property` for Open Graph `<meta>` tags
- `sandbox`, `seamless`, and `srcDoc` for `<iframe>` tags
- `scope` for screen readers
- `span` for `<colgroup>` tags
- Added support for defining `propTypes` in mixins
- Added `any`, `arrayOf`, `component`, `oneOfType`, `renderable`, `shape` to `React.PropTypes`
- Added support for `statics` on component spec for static component methods
- On all events, `.currentTarget` is now properly set
- On keyboard events, `.key` is now polyfilled in all browsers for special (non-printable) keys
- On clipboard events, `.clipboardData` is now polyfilled in IE
- On drag events, `.dragTransfer` is now present
- Added support for `onMouseOver` and `onMouseOut` in addition to the existing `onMouseEnter` and `onMouseLeave` events
- Added support for `onLoad` and `onError` on `<img>` elements
- Added support for `onReset` on `<form>` elements
- The `autoFocus` attribute is now polyfilled consistently on `input`, `select`, and `textarea`
#### Bug Fixes
- React no longer adds an `__owner__` property to each component's `props` object; passed-in props are now never mutated
- When nesting top-level components (e.g., calling `React.renderComponent` within `componentDidMount`), events now properly bubble to the parent component
- Fixed a case where nesting top-level components would throw an error when updating
- Passing an invalid or misspelled propTypes type now throws an error
- On mouse enter/leave events, `.target`, `.relatedTarget`, and `.type` are now set properly
- On composition events, `.data` is now properly normalized in IE9 and IE10
- CSS property values no longer have `px` appended for the unitless properties `columnCount`, `flex`, `flexGrow`, `flexShrink`, `lineClamp`, `order`, `widows`
- Fixed a memory leak when unmounting children with a `componentWillUnmount` handler
- Fixed a memory leak when `renderComponentToString` would store event handlers
- Fixed an error that could be thrown when removing form elements during a click handler
- Boolean attributes such as `disabled` are rendered without a value (previously `disabled="true"`, now simply `disabled`)
- `key` values containing `.` are now supported
- Shortened `data-reactid` values for performance
- Components now always remount when the `key` property changes
- Event handlers are attached to `document` only when necessary, improving performance in some cases
- Events no longer use `.returnValue` in modern browsers, eliminating a warning in Chrome
- `scrollLeft` and `scrollTop` are no longer accessed on document.body, eliminating a warning in Chrome
- General performance fixes, memory optimizations, improvements to warnings and error messages
### React with Addons
- `React.addons.TestUtils` was added to help write unit tests
- `React.addons.TransitionGroup` was renamed to `React.addons.CSSTransitionGroup`
- `React.addons.TransitionGroup` was added as a more general animation wrapper
- `React.addons.cloneWithProps` was added for cloning components and modifying their props
- Bug fix for adding back nodes during an exit transition for CSSTransitionGroup
- Bug fix for changing `transitionLeave` in CSSTransitionGroup
- Performance optimizations for CSSTransitionGroup
- On checkbox `<input>` elements, `checkedLink` is now supported for two-way binding
### JSX Compiler and react-tools Package
- Whitespace normalization has changed; now space between two tags on the same line will be preserved, while newlines between two tags will be removed
- The `react-tools` npm package no longer includes the React core libraries; use the `react` package instead.
- `displayName` is now added in more cases, improving error messages and names in the React Dev Tools
- Fixed an issue where an invalid token error was thrown after a JSX closing tag
- `JSXTransformer` now uses source maps automatically in modern browsers
- `JSXTransformer` error messages now include the filename and problematic line contents when a file fails to parse
## 0.8.0 (December 19, 2013)
### React
* Added support for more attributes:
* `rows` & `cols` for `<textarea>`
* `defer` & `async` for `<script>`
* `loop` for `<audio>` & `<video>`
* `autoCorrect` for form fields (a non-standard attribute only supported by mobile WebKit)
* Improved error messages
* Fixed Selection events in IE11
* Added `onContextMenu` events
### React with Addons
* Fixed bugs with TransitionGroup when children were undefined
* Added support for `onTransition`
### react-tools
* Upgraded `jstransform` and `esprima-fb`
### JSXTransformer
* Added support for use in IE8
* Upgraded browserify, which reduced file size by ~65KB (16KB gzipped)
## 0.5.2, 0.4.2 (December 18, 2013)
### React
* Fixed a potential XSS vulnerability when using user content as a `key`: [CVE-2013-7035](https://groups.google.com/forum/#!topic/reactjs/OIqxlB2aGfU)
## 0.5.1 (October 29, 2013)
### React
* Fixed bug with `<input type="range">` and selection events.
* Fixed bug with selection and focus.
* Made it possible to unmount components from the document root.
* Fixed bug for `disabled` attribute handling on non-`<input>` elements.
### React with Addons
* Fixed bug with transition and animation event detection.
## 0.5.0 (October 16, 2013)
### React
* Memory usage improvements - reduced allocations in core which will help with GC pauses
* Performance improvements - in addition to speeding things up, we made some tweaks to stay out of slow path code in V8 and Nitro.
* Standardized prop -> DOM attribute process. This previously resulting in additional type checking and overhead as well as confusing cases for users. Now we will always convert your value to a string before inserting it into the DOM.
* Support for Selection events.
* Support for [Composition events](https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent).
* Support for additional DOM properties (`charSet`, `content`, `form`, `httpEquiv`, `rowSpan`, `autoCapitalize`).
* Support for additional SVG properties (`rx`, `ry`).
* Support for using `getInitialState` and `getDefaultProps` in mixins.
* Support mounting into iframes.
* Bug fixes for controlled form components.
* Bug fixes for SVG element creation.
* Added `React.version`.
* Added `React.isValidClass` - Used to determine if a value is a valid component constructor.
* Removed `React.autoBind` - This was deprecated in v0.4 and now properly removed.
* Renamed `React.unmountAndReleaseReactRootNode` to `React.unmountComponentAtNode`.
* Began laying down work for refined performance analysis.
* Better support for server-side rendering - [react-page](https://github.com/facebook/react-page) has helped improve the stability for server-side rendering.
* Made it possible to use React in environments enforcing a strict [Content Security Policy](https://developer.mozilla.org/en-US/docs/Security/CSP/Introducing_Content_Security_Policy). This also makes it possible to use React to build Chrome extensions.
### React with Addons (New!)
* Introduced a separate build with several "addons" which we think can help improve the React experience. We plan to deprecate this in the long-term, instead shipping each as standalone pieces. [Read more in the docs](http://facebook.github.io/react/docs/addons.html).
### JSX
* No longer transform `class` to `className` as part of the transform! This is a breaking change - if you were using `class`, you *must* change this to `className` or your components will be visually broken.
* Added warnings to the in-browser transformer to make it clear it is not intended for production use.
* Improved compatibility for Windows
* Improved support for maintaining line numbers when transforming.
## 0.4.1 (July 26, 2013)
### React

View File

@@ -57,6 +57,7 @@ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
* `"use strict";`
* 80 character line length
* "Attractive"
* Do not use the optional parameters of `setTimeout` and `setInterval`
## License

View File

@@ -3,76 +3,206 @@
var exec = require('child_process').exec;
var jsxTask = require('./grunt/tasks/jsx');
var browserifyTask = require('./grunt/tasks/browserify');
var wrapupTask = require('./grunt/tasks/wrapup');
var populistTask = require('./grunt/tasks/populist');
var phantomTask = require('./grunt/tasks/phantom');
var webdriverPhantomJSTask = require('./grunt/tasks/webdriver-phantomjs');
var webdriverJasmineTasks = require('./grunt/tasks/webdriver-jasmine');
var sauceTunnelTask = require('./grunt/tasks/sauce-tunnel');
var npmTask = require('./grunt/tasks/npm');
var releaseTasks = require('./grunt/tasks/release');
var npmReactTasks = require('./grunt/tasks/npm-react');
var npmReactToolsTasks = require('./grunt/tasks/npm-react-tools');
var versionCheckTask = require('./grunt/tasks/version-check');
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: require('./grunt/config/copy'),
jsx: require('./grunt/config/jsx/jsx'),
jsx: require('./grunt/config/jsx'),
browserify: require('./grunt/config/browserify'),
wrapup: require('./grunt/config/wrapup'),
populist: require('./grunt/config/populist'),
phantom: require('./grunt/config/phantom'),
connect: require('./grunt/config/server')(grunt),
"webdriver-jasmine": require('./grunt/config/webdriver-jasmine'),
"webdriver-perf": require('./grunt/config/webdriver-perf'),
npm: require('./grunt/config/npm'),
clean: ['./build', './*.gem', './docs/_site', './examples/shared/*.js'],
clean: ['./build', './*.gem', './docs/_site', './examples/shared/*.js', '.module-cache'],
jshint: require('./grunt/config/jshint'),
compare_size: require('./grunt/config/compare_size')
compare_size: require('./grunt/config/compare_size'),
complexity: require('./grunt/config/complexity')
});
grunt.config.set('compress', require('./grunt/config/compress'));
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-compare-size');
grunt.loadNpmTasks('grunt-contrib-compress');
Object.keys(grunt.file.readJSON('package.json').devDependencies)
.filter(function(npmTaskName) { return npmTaskName.indexOf('grunt-') === 0; })
.filter(function(npmTaskName) { return npmTaskName != 'grunt-cli'; })
.forEach(function(npmTaskName) { grunt.loadNpmTasks(npmTaskName); });
// Alias 'jshint' to 'lint' to better match the workflow we know
grunt.registerTask('lint', ['jshint']);
// Register jsx:debug and :release tasks.
grunt.registerTask('download-previous-version', require('./grunt/tasks/download-previous-version.js'));
grunt.registerTask('delete-build-modules', function() {
if (grunt.file.exists('build/modules')) {
grunt.file.delete('build/modules');
}
});
// Register jsx:normal and :release tasks.
grunt.registerMultiTask('jsx', jsxTask);
// Our own browserify-based tasks to build a single JS file build
grunt.registerMultiTask('browserify', browserifyTask);
// Similar to Browserify, use WrapUp to generate single JS file that
// defines global variables instead of using require.
grunt.registerMultiTask('wrapup', wrapupTask);
grunt.registerMultiTask('populist', populistTask);
grunt.registerMultiTask('phantom', phantomTask);
grunt.registerTask('sauce-tunnel', sauceTunnelTask);
grunt.registerMultiTask('webdriver-jasmine', webdriverJasmineTasks);
grunt.registerMultiTask('webdriver-perf', require('./grunt/tasks/webdriver-perf'));
grunt.registerMultiTask('npm', npmTask);
grunt.registerTask('build:basic', ['jsx:debug', 'browserify:basic']);
grunt.registerTask('build:transformer', ['jsx:debug', 'browserify:transformer']);
grunt.registerTask('build:min', ['jsx:release', 'browserify:min']);
grunt.registerTask('npm-react:release', npmReactTasks.buildRelease);
grunt.registerTask('npm-react:pack', npmReactTasks.packRelease);
grunt.registerTask('npm-react-tools:pack', npmReactToolsTasks.pack);
grunt.registerTask('version-check', versionCheckTask);
grunt.registerTask('build:basic', ['jsx:normal', 'version-check', 'browserify:basic']);
grunt.registerTask('build:addons', ['jsx:normal', 'browserify:addons']);
grunt.registerTask('build:transformer', ['jsx:normal', 'browserify:transformer']);
grunt.registerTask('build:min', ['jsx:normal', 'version-check', 'browserify:min']);
grunt.registerTask('build:addons-min', ['jsx:normal', 'browserify:addonsMin']);
grunt.registerTask('build:withCodeCoverageLogging', [
'jsx:normal',
'version-check',
'browserify:withCodeCoverageLogging'
]);
grunt.registerTask('build:perf', [
'jsx:normal',
'version-check',
'browserify:transformer',
'browserify:basic',
'browserify:min',
'download-previous-version'
]);
grunt.registerTask('build:test', [
'jsx:jasmine',
'delete-build-modules',
'jsx:test',
'populist:jasmine',
'version-check',
'populist:test'
]);
grunt.registerTask('build:npm-react', ['version-check', 'jsx:normal', 'npm-react:release']);
grunt.registerTask('test', ['build:test', 'phantom:run']);
grunt.registerTask('webdriver-phantomjs', webdriverPhantomJSTask);
grunt.registerTask('coverage:parse', require('./grunt/tasks/coverage-parse'));
grunt.registerTask('test:webdriver:phantomjs', [
'connect',
'webdriver-phantomjs',
'webdriver-jasmine:local'
]);
grunt.registerTask('perf:webdriver:phantomjs', [
'connect',
'webdriver-phantomjs',
'webdriver-perf:local'
]);
grunt.registerTask('test:full', [
'build:test',
'build:basic',
'connect',
'webdriver-phantomjs',
'webdriver-jasmine:local',
'sauce-tunnel',
'webdriver-jasmine:saucelabs_android',
'webdriver-jasmine:saucelabs_firefox',
'webdriver-jasmine:saucelabs_chrome'
]);
grunt.registerTask('perf:full', [
'build:perf',
'connect',
'webdriver-phantomjs',
'webdriver-perf:local',
'sauce-tunnel',
'webdriver-perf:saucelabs_firefox',
'webdriver-perf:saucelabs_chrome',
'webdriver-perf:saucelabs_ie11',
'webdriver-perf:saucelabs_ie8',
]);
grunt.registerTask('test:webdriver:saucelabs', [
'build:test',
'build:basic',
'connect',
'sauce-tunnel',
'webdriver-jasmine:saucelabs_' + (process.env.BROWSER_NAME || 'ie8')
]);
grunt.registerTask('test:webdriver:saucelabs:ie', [
'build:test',
'build:basic',
'connect',
'sauce-tunnel',
'webdriver-jasmine:saucelabs_ie8',
'webdriver-jasmine:saucelabs_ie9',
'webdriver-jasmine:saucelabs_ie10',
'webdriver-jasmine:saucelabs_ie11'
]);
grunt.registerTask('test:webdriver:saucelabs:ios', [
'build:test',
'build:basic',
'connect',
'sauce-tunnel',
'webdriver-jasmine:saucelabs_ios6_1',
'webdriver-jasmine:saucelabs_ios5_1',
'webdriver-jasmine:saucelabs_ios4'
]);
grunt.registerTask('test:coverage', [
'build:test',
'build:withCodeCoverageLogging',
'test:webdriver:phantomjs',
'coverage:parse'
]);
grunt.registerTask('test', function() {
if (grunt.option('debug')) {
grunt.task.run('build:test', 'build:basic', 'connect:server:keepalive');
} else {
grunt.task.run('build:test', 'build:basic', 'test:webdriver:phantomjs');
}
});
grunt.registerTask('perf', ['build:perf', 'perf:webdriver:phantomjs']);
grunt.registerTask('npm:test', ['build', 'npm:pack']);
// Optimized build task that does all of our builds. The subtasks will be run
// in order so we can take advantage of that and only run jsx:debug once.
// in order so we can take advantage of that and only run jsx:normal once.
grunt.registerTask('build', [
'jsx:debug',
'delete-build-modules',
'jsx:normal',
'version-check',
'browserify:basic',
'browserify:transformer',
'jsx:release',
'browserify:addons',
'browserify:min',
'browserify:addonsMin',
'npm-react:release',
'npm-react:pack',
'npm-react-tools:pack',
'copy:react_docs',
'compare_size'
]);

View File

@@ -2,21 +2,25 @@
React is a JavaScript library for building user interfaces.
* **Declarative:** React uses a declarative paradigm that makes it easier to reason about your application.
* **Efficient:** React computes the minimal set of changes necessary to keep your DOM up-to-date.
* **Flexible:** React works with the libraries and frameworks that you already know.
* **Just the UI:** Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it's easy to try it out on a small feature in an existing project.
* **Virtual DOM:** React uses a *virtual DOM* diff implementation for ultra-high performance. It can also render on the server using Node.js — no heavy browser DOM required.
* **Data flow:** React implements one-way reactive data flow which reduces boilerplate and is easier to reason about than traditional data binding.
[Learn how to use React in your own project.](http://facebook.github.io/react/docs/getting-started.html)
## The `react` npm package has recently changed!
If you're looking for jeffbski's [React.js](https://github.com/jeffbski/autoflow) project, it's now in `npm` as `autoflow` rather than `react`.
## Examples
We have several examples [on the website](http://facebook.github.io/react). Here is the first one to get you started:
We have several examples [on the website](http://facebook.github.io/react/). Here is the first one to get you started:
```js
/** @jsx React.DOM */
var HelloMessage = React.createClass({
render: function() {
return <div>{'Hello ' + this.props.name}</div>;
return <div>Hello {this.props.name}</div>;
}
});
@@ -28,7 +32,7 @@ React.renderComponent(
This example will render "Hello John" into a container on the page.
You'll notice that we used an XML-like syntax; [we call it JSX](http://facebook.github.io/react/docs/syntax.html). JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. A simple transform is included with React that allows converting JSX into native JavaScript for browsers to digest.
You'll notice that we used an HTML-like syntax; [we call it JSX](http://facebook.github.io/react/docs/jsx-in-depth.html). JSX is not required to use React, but it makes code more readable, and writing it feels like writing HTML. A simple transform is included with React that allows converting JSX into native JavaScript for browsers to digest.
## Installation
@@ -36,12 +40,12 @@ The fastest way to get started is to serve JavaScript from the CDN (also availab
```html
<!-- The core React library -->
<script src="http://fb.me/react-0.4.1.min.js"></script>
<script src="http://fb.me/react-0.9.0.js"></script>
<!-- In-browser JSX transformer, remove when pre-compiling JSX. -->
<script src="http://fb.me/JSXTransformer-0.4.1.js"></script>
<script src="http://fb.me/JSXTransformer-0.9.0.js"></script>
```
We've also built a [starter kit](http://facebook.github.io/react/downloads/react-0.4.1.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
We've also built a [starter kit](http://facebook.github.io/react/downloads/react-0.9.0.zip) which might be useful if this is your first time using React. It includes a webpage with an example of using React with live code.
If you'd like to use [bower](http://bower.io), it's as easy as:
@@ -51,7 +55,7 @@ bower install --save react
## Contribute
The main purpose of this repository is to continue to evolve React core, making it faster and easier to use. If you're interested in helping with that, then keep reading. If you're not interested in helping right now that's ok too :) Any feedback you have about using React would be greatly appreciated.
The main purpose of this repository is to continue to evolve React core, making it faster and easier to use. If you're interested in helping with that, then keep reading. If you're not interested in helping right now that's ok too. :) Any feedback you have about using React would be greatly appreciated.
### Building Your Copy of React
@@ -81,12 +85,12 @@ At this point, you should now have a `build/` directory populated with everythin
We use grunt to automate many tasks. Run `grunt -h` to see a mostly complete listing. The important ones to know:
```sh
# Create test build & run tests with PhantomJS
# Build and run tests with PhantomJS
grunt test
# Lint the core library code with JSHint
# Build and run tests in your browser
grunt test --debug
# Lint the code with JSHint
grunt lint
# Lint package code
grunt lint:package
# Wipe out build directory
grunt clean
```

65
bin/jsx
View File

@@ -1,55 +1,24 @@
#!/usr/bin/env node
// -*- mode: js -*-
"use strict";
var visitors = require('../vendor/fbtransform/visitors').transformVisitors;
var transform = require('../vendor/fbtransform/lib/transform').transform;
var propagate = require("../vendor/constants").propagate;
require("commoner").resolve(function(id) {
var context = this;
// Note that the result of context.getProvidedP() is cached for the
// duration of the build, so it is both consistent and cheap to
// evaluate multiple times.
return context.getProvidedP().then(function(idToPath) {
// If a module declares its own identifier using @providesModule
// then that identifier will be a key in the idToPath object.
if (idToPath.hasOwnProperty(id)) {
return context.readFileP(idToPath[id]);
}
// Otherwise assume the identifier maps directly to a path in the
// filesystem.
return context.readModuleP(id);
});
}).process(function(id, source) {
var context = this;
var constants = context.config.constants || {};
var visitors = require('../vendor/fbtransform/visitors');
var transform = require('jstransform').transform;
require('commoner').version(
require('../package.json').version
).resolve(function(id) {
return this.readModuleP(id);
}).option(
'--harmony',
'Turns on JS transformations such as ES6 Classes etc.'
).process(function(id, source) {
// This is where JSX, ES6, etc. desugaring happens.
source = transform(visitors.react, source).code;
// Constant propagation means removing any obviously dead code after
// replacing constant expressions with literal (boolean) values.
source = propagate(constants, source);
if (context.config.mocking) {
// Make sure there is exactly one newline at the end of the module.
source = source.replace(/\s+$/m, "\n");
return context.getProvidedP().then(function(idToPath) {
if (id !== "mock-modules" &&
id !== "mocks" &&
id !== "test/all" &&
idToPath.hasOwnProperty("mock-modules")) {
return source + '\nrequire("mock-modules").register(' +
JSON.stringify(id) + ', module);\n';
}
return source;
});
var visitorList;
if (this.options.harmony) {
visitorList = visitors.getAllVisitors();
} else {
visitorList = visitors.transformVisitors.react;
}
return source;
return transform(visitorList, source).code;
});

58
bin/jsx-internal Executable file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/env node
// -*- mode: js -*-
"use strict";
var getAllVisitors = require('../vendor/fbtransform/visitors').getAllVisitors;
var transform = require('jstransform').transform;
var propagate = require("../vendor/constants").propagate;
require("commoner").version(
require("../package.json").version
).resolve(function(id) {
var context = this;
// Note that the result of context.getProvidedP() is cached for the
// duration of the build, so it is both consistent and cheap to
// evaluate multiple times.
return context.getProvidedP().then(function(idToPath) {
// If a module declares its own identifier using @providesModule
// then that identifier will be a key in the idToPath object.
if (idToPath.hasOwnProperty(id)) {
return context.readFileP(idToPath[id]);
}
// Otherwise assume the identifier maps directly to a path in the
// filesystem.
return context.readModuleP(id);
});
}).process(function(id, source) {
var context = this;
var constants = context.config.constants || {};
// This is where JSX, ES6, etc. desugaring happens.
source = transform(getAllVisitors(), source).code;
// Constant propagation means removing any obviously dead code after
// replacing constant expressions with literal (boolean) values.
source = propagate(constants, source);
if (context.config.mocking) {
// Make sure there is exactly one newline at the end of the module.
source = source.replace(/\s+$/m, "\n");
return context.getProvidedP().then(function(idToPath) {
if (id !== "mock-modules" &&
id !== "mocks" &&
id !== "test/all" &&
idToPath.hasOwnProperty("mock-modules")) {
return source + '\nrequire("mock-modules").register(' +
JSON.stringify(id) + ', module);\n';
}
return source;
});
}
return source;
});

View File

@@ -3,7 +3,7 @@ source 'https://rubygems.org'
gem 'rake'
# jekyll, which builds it all
gem 'jekyll', '~>1.0'
gem 'jekyll', '~>1.3.0'
# JSON
gem 'json'

View File

@@ -4,40 +4,47 @@ GEM
classifier (1.3.3)
fast-stemmer (>= 1.0.0)
colorator (0.1)
commander (4.1.3)
commander (4.1.5)
highline (~> 1.6.11)
directory_watcher (1.4.1)
fast-stemmer (1.0.2)
highline (1.6.19)
jekyll (1.0.2)
ffi (1.9.3)
highline (1.6.20)
jekyll (1.3.0)
classifier (~> 1.3)
colorator (~> 0.1)
commander (~> 4.1.3)
directory_watcher (~> 1.4.1)
kramdown (~> 1.0.2)
liquid (~> 2.3)
maruku (~> 0.5)
liquid (~> 2.5.2)
listen (~> 1.3)
maruku (~> 0.6.0)
pygments.rb (~> 0.5.0)
safe_yaml (~> 0.7.0)
json (1.8.0)
kramdown (1.0.2)
liquid (2.5.0)
redcarpet (~> 2.3.0)
safe_yaml (~> 0.9.7)
json (1.8.1)
liquid (2.5.4)
listen (1.3.1)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
maruku (0.6.1)
syntax (>= 1.0.0)
mini_portile (0.5.1)
mini_portile (0.5.2)
nokogiri (1.6.0)
mini_portile (~> 0.5.0)
posix-spawn (0.3.6)
pygments.rb (0.5.0)
pygments.rb (0.5.4)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rake (10.0.4)
rake (10.1.0)
rb-fsevent (0.9.3)
redcarpet (2.2.2)
safe_yaml (0.7.1)
rb-inotify (0.9.2)
ffi (>= 0.5.0)
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
redcarpet (2.3.0)
safe_yaml (0.9.7)
sanitize (2.0.6)
nokogiri (>= 1.4.4)
sass (3.2.9)
sass (3.2.12)
syntax (1.0.0)
yajl-ruby (1.1.0)
@@ -45,7 +52,7 @@ PLATFORMS
ruby
DEPENDENCIES
jekyll (~> 1.0)
jekyll (~> 1.3.0)
json
rake
rb-fsevent

View File

@@ -21,6 +21,7 @@ Once you have RubyGems and installed Bundler (via `gem install bundler`), use it
```sh
$ cd react/docs
$ bundle install # Might need sudo.
$ npm install # Might need sudo.
```
### Instructions

View File

@@ -13,57 +13,9 @@ redcarpet:
pygments: true
name: React
markdown: redcarpet
react_version: 0.4.2
react_version: 0.10.0-alpha
description: A JavaScript library for building user interfaces
relative_permalinks: true
paginate: 5
paginate_path: /blog/page:num
nav_docs_sections:
- title: Quick Start
items:
- id: getting-started
title: Getting Started
- id: tutorial
title: Tutorial
- title: Guides
items:
- id: why-react
title: Why React?
- id: displaying-data
title: Displaying Data
subitems:
- id: jsx-in-depth
title: JSX in Depth
- id: jsx-gotchas
title: JSX Gotchas
- id: interactivity-and-dynamic-uis
title: Interactivity and Dynamic UIs
- id: multiple-components
title: Multiple Components
- id: reusable-components
title: Reusable Components
- id: forms
title: Forms
- id: working-with-the-browser
title: Working With the Browser
subitems:
- id: more-about-refs
title: More About Refs
- id: tooling-integration
title: Tooling Integration
- id: examples
title: Examples
- title: Reference
items:
- id: top-level-api
title: Top-Level API
- id: component-api
title: Component API
- id: component-specs
title: Component Specs and Lifecycle
- id: tags-and-attributes
title: Supported Tags and Attributes
- id: events
title: Event System
- id: dom-differences
title: DOM Differences
paginate_path: /blog/page:num/
timezone: America/Los_Angeles

View File

@@ -15,6 +15,7 @@ $contentPadding: 20px;
$columnWidth: 280px;
$columnGutter: 40px;
$twoColumnWidth: 2 * $columnWidth + $columnGutter;
$navHeight: 50px;
@@ -42,7 +43,7 @@ html {
.container {
padding-top: 50px;
padding-top: $navHeight;
min-width: $contentWidth + (2 * $contentPadding);
}
@@ -73,6 +74,23 @@ li {
margin-left: 20px;
}
// Make header navigation linkable and on the screen. Used in documentation and
// blog posts.
h1, h2, h3, h4, h5, h6 {
.anchor {
margin-top: -$navHeight;
position: absolute;
}
&:hover .hash-link {
display: inline;
}
}
.hash-link {
color: $mediumTextColor;
display: none;
}
// Main Nav
.nav-main {
@@ -81,7 +99,7 @@ li {
color: $lightTextColor;
position: fixed;
top: 0;
height: 50px;
height: $navHeight;
box-shadow: 0 0 5px rgba(0, 0, 0, .5);
width: 100%;
z-index: 100;
@@ -103,9 +121,9 @@ li {
padding: 0 8px;
text-transform: uppercase;
letter-spacing: 1px;
line-height: 50px;
line-height: $navHeight;
display: inline-block;
height: 50px;
height: $navHeight;
color: $mediumTextColor;
&:hover {
@@ -123,7 +141,7 @@ li {
.nav-home {
color: #00d8ff;
font-size: 24px;
line-height: 50px;
line-height: $navHeight;
}
.nav-logo {
@@ -272,7 +290,7 @@ li {
.marketing-col {
float: left;
margin-right: 40px;
margin-left: 40px;
width: $columnWidth;
h3 {
@@ -286,8 +304,8 @@ li {
}
}
.marketing-col:last-child {
margin-right: 0;
.marketing-col:first-child {
margin-left: 0;
}
#examples h3, .home-presentation h3 {
@@ -369,6 +387,8 @@ section.black content {
*/
.blogContent {
@include clearfix;
padding-top: 20px;
blockquote {
@@ -391,6 +411,7 @@ section.black content {
font-size: 24px;
}
// H2s form documentation topic dividers. Extra space helps.
h2 {
margin-top: 30px;
@@ -398,7 +419,7 @@ section.black content {
padding-top: 20px;
// Make a notice box out of blockquotes in the documetation:
// Make a notice box out of blockquotes in the documentation:
blockquote {
padding: 15px 30px 15px 15px;
margin: 20px 0;
@@ -407,7 +428,7 @@ section.black content {
h4 {
margin-top: 0;
}
p:last-child {
p {
margin-bottom: 0;
}
// Treat first child as the title - promote to H4.
@@ -438,13 +459,19 @@ section.black content {
}
.playgroundPreview {
padding: 14px;
padding: 0;
width: 600px;
pre {
@include code-typography;
}
}
.playgroundError {
// The compiler view kills padding in order to render the CodeMirror code
// more nicely. For the error view, put a padding back
padding: 15px 20px;
}
}
/* Button */
@@ -539,7 +566,7 @@ figure {
margin-top: 60px;
}
/* Code Mirror */
/* CodeMirror */
div.CodeMirror pre, div.CodeMirror-linenumber, code {
@include code-typography;
@@ -553,6 +580,11 @@ div.CodeMirror-linenumber:after {
border: none;
}
/* hide the cursor. Mostly used when code's in plain JS */
.CodeMirror-readonly div.CodeMirror-cursor {
visibility: hidden;
}
small code,
li code,
p code {
@@ -569,23 +601,28 @@ p code {
@include clearfix;
}
.playground::before {
.playground-tab {
border-bottom: none !important;
border-radius: 3px 3px 0 0;
padding: 3px 7px;
padding: 6px 8px;
font-size: 12px;
font-weight: bold;
color: #c2c0bc;
background-color: #f1ede4;
content: 'Live editor';
display: inline-block;
cursor: pointer;
}
.playground::before,
.playgroundCode,
.playground-tab,
.playgroundPreview {
border: 1px solid rgba(16,16,16,0.1);
}
.playground-tab-active {
color: $darkestColor;
}
.playgroundCode {
border-radius: 0 3px 3px 3px;
float: left;
@@ -601,6 +638,11 @@ p code {
width: $columnWidth;
}
.playgroundError {
color: darken($primary, 5%);
font-size: 15px;
}
.MarkdownEditor textarea {
width: 100%;
height: 100px
@@ -615,7 +657,7 @@ p code {
padding-left: 9px;
}
/* Codemirror doesn't support <jsx> syntax. Instead of highlighting it
/* CodeMirror doesn't support <jsx> syntax. Instead of highlighting it
as error, just ignore it */
.highlight .javascript .err {
background-color: transparent;
@@ -702,3 +744,24 @@ p code {
float: right;
}
}
// Twitter embeds. Need to !important because they inline margin on the iframe.
div[data-twttr-id] iframe {
margin: 10px auto !important;
}
/* Acknowledgements */
.three-column {
@include clearfix;
}
.three-column > ul {
float: left;
margin-left: 30px;
width: 190px;
}
.three-column > ul:first-child {
margin-left: 20px;
}

75
docs/_data/nav_docs.yml Normal file
View File

@@ -0,0 +1,75 @@
- title: Quick Start
items:
- id: getting-started
title: Getting Started
- id: tutorial
title: Tutorial
- id: thinking-in-react
title: Thinking in React
- title: Community Resources
items:
- id: videos
title: Videos
- id: complementary-tools
title: Complementary Tools
- id: examples
title: Examples
- title: Guides
items:
- id: why-react
title: Why React?
- id: displaying-data
title: Displaying Data
subitems:
- id: jsx-in-depth
title: JSX in Depth
- id: jsx-gotchas
title: JSX Gotchas
- id: interactivity-and-dynamic-uis
title: Interactivity and Dynamic UIs
- id: multiple-components
title: Multiple Components
- id: reusable-components
title: Reusable Components
- id: forms
title: Forms
- id: working-with-the-browser
title: Working With the Browser
subitems:
- id: more-about-refs
title: More About Refs
- id: tooling-integration
title: Tooling Integration
- id: addons
title: Add-Ons
subitems:
- id: animation
title: Animation
- id: two-way-binding-helpers
title: Two-Way Binding Helpers
- id: class-name-manipulation
title: Class Name Manipulation
- id: test-utils
title: Test Utilities
- id: clone-with-props
title: Cloning Components
- id: update
title: Immutability Helpers
- title: Reference
items:
- id: top-level-api
title: Top-Level API
- id: component-api
title: Component API
- id: component-specs
title: Component Specs and Lifecycle
- id: tags-and-attributes
title: Supported Tags and Attributes
- id: events
title: Event System
- id: dom-differences
title: DOM Differences
- id: special-non-dom-attributes
title: Special Non-DOM Attributes
- id: reconciliation
title: Reconciliation

32
docs/_data/nav_tips.yml Normal file
View File

@@ -0,0 +1,32 @@
- title: Tips
items:
- id: introduction
title: Introduction
- id: inline-styles
title: Inline Styles
- id: if-else-in-JSX
title: If-Else in JSX
- id: self-closing-tag
title: Self-Closing Tag
- id: maximum-number-of-jsx-root-nodes
title: Maximum Number of JSX Root Nodes
- id: style-props-value-px
title: Shorthand for Specifying Pixel Values in style props
- id: children-props-type
title: Type of the Children props
- id: controlled-input-null-value
title: Value of null for Controlled Input
- id: componentWillReceiveProps-not-triggered-after-mounting
title: componentWillReceiveProps Not Triggered After Mounting
- id: props-in-getInitialState-as-anti-pattern
title: Props in getInitialState Is an Anti-Pattern
- id: dom-event-listeners
title: DOM Event Listeners in a Component
- id: initial-ajax
title: Load Initial Data via AJAX
- id: false-in-jsx
title: False in JSX
- id: communicate-between-components
title: Communicate Between Components
- id: expose-component-functions
title: Expose Component Functions

View File

@@ -1,5 +1,6 @@
<div class="nav-docs">
{% for section in site.nav_docs_sections %}
<!-- Docs Nav -->
{% for section in site.data.nav_docs %}
<div class="nav-docs-section">
<h3>{{ section.title }}</h3>
<ul>
@@ -24,4 +25,18 @@
</ul>
</div>
{% endfor %}
<!-- Tips Nav -->
{% for section in site.data.nav_tips %}
<div class="nav-docs-section">
<h3>{{ section.title }}</h3>
<ul>
{% for item in section.items %}
<li>
<a href="/react/tips/{{ item.id }}.html"{% if page.id == item.id %} class="active"{% endif %}>{{ item.title }}</a>
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>

2
docs/_js/es5-sham.min.js vendored Normal file

File diff suppressed because one or more lines are too long

2
docs/_js/es5-shim.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@ var HELLO_COMPONENT = "\
/** @jsx React.DOM */\n\
var HelloMessage = React.createClass({\n\
render: function() {\n\
return <div>{'Hello ' + this.props.name}</div>;\n\
return <div>Hello {this.props.name}</div>;\n\
}\n\
});\n\
\n\

View File

@@ -3,6 +3,7 @@
*/
var TIMER_COMPONENT = "\
/** @jsx React.DOM */\n\
var Timer = React.createClass({\n\
getInitialState: function() {\n\
return {secondsElapsed: 0};\n\
@@ -17,13 +18,13 @@ var Timer = React.createClass({\n\
clearInterval(this.interval);\n\
},\n\
render: function() {\n\
return React.DOM.div({},\n\
'Seconds Elapsed: ' + this.state.secondsElapsed\n\
return (\n\
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>\n\
);\n\
}\n\
});\n\
\n\
React.renderComponent(Timer({}), mountNode);\
React.renderComponent(<Timer />, mountNode);\
";
React.renderComponent(

482
docs/_js/html-jsx-lib.js Normal file
View File

@@ -0,0 +1,482 @@
/**
* Copyright 2013-2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This is a very simple HTML to JSX converter. It turns out that browsers
* have good HTML parsers (who would have thought?) so we utilise this by
* inserting the HTML into a temporary DOM node, and then do a breadth-first
* traversal of the resulting DOM tree.
*/
;(function(global) {
'use strict';
// https://developer.mozilla.org/en-US/docs/Web/API/Node.nodeType
var NODE_TYPE = {
ELEMENT: 1,
TEXT: 3,
COMMENT: 8
};
var ATTRIBUTE_MAPPING = {
'for': 'htmlFor',
'class': 'className'
};
/**
* Repeats a string a certain number of times.
* Also: the future is bright and consists of native string repetition:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat
*
* @param {string} string String to repeat
* @param {number} times Number of times to repeat string. Integer.
* @see http://jsperf.com/string-repeater/2
*/
function repeatString(string, times) {
if (times === 1) {
return string;
}
if (times < 0) { throw new Error(); }
var repeated = '';
while (times) {
if (times & 1) {
repeated += string;
}
if (times >>= 1) {
string += string;
}
}
return repeated;
}
/**
* Determine if the string ends with the specified substring.
*
* @param {string} haystack String to search in
* @param {string} needle String to search for
* @return {boolean}
*/
function endsWith(haystack, needle) {
return haystack.slice(-needle.length) === needle;
}
/**
* Trim the specified substring off the string. If the string does not end
* with the specified substring, this is a no-op.
*
* @param {string} haystack String to search in
* @param {string} needle String to search for
* @return {string}
*/
function trimEnd(haystack, needle) {
return endsWith(haystack, needle)
? haystack.slice(0, -needle.length)
: haystack;
}
/**
* Convert a hyphenated string to camelCase.
*/
function hyphenToCamelCase(string) {
return string.replace(/-(.)/g, function(match, chr) {
return chr.toUpperCase();
});
}
/**
* Determines if the specified string consists entirely of whitespace.
*/
function isEmpty(string) {
return !/[^\s]/.test(string);
}
/**
* Determines if the specified string consists entirely of numeric characters.
*/
function isNumeric(input) {
return input !== undefined
&& input !== null
&& (typeof input === 'number' || parseInt(input, 10) == input);
}
var HTMLtoJSX = function(config) {
this.config = config || {};
if (this.config.createClass === undefined) {
this.config.createClass = true;
}
if (!this.config.indent) {
this.config.indent = ' ';
}
if (!this.config.outputClassName) {
this.config.outputClassName = 'NewComponent';
}
};
HTMLtoJSX.prototype = {
/**
* Reset the internal state of the converter
*/
reset: function() {
this.output = '';
this.level = 0;
},
/**
* Main entry point to the converter. Given the specified HTML, returns a
* JSX object representing it.
* @param {string} html HTML to convert
* @return {string} JSX
*/
convert: function(html) {
this.reset();
// It turns out browsers have good HTML parsers (imagine that).
// Let's take advantage of it.
var containerEl = document.createElement('div');
containerEl.innerHTML = '\n' + this._cleanInput(html) + '\n';
if (this.config.createClass) {
if (this.config.outputClassName) {
this.output = 'var ' + this.config.outputClassName + ' = React.createClass({\n';
} else {
this.output = 'React.createClass({\n';
}
this.output += this.config.indent + 'render: function() {' + "\n";
this.output += this.config.indent + this.config.indent + 'return (\n';
}
if (this._onlyOneTopLevel(containerEl)) {
// Only one top-level element, the component can return it directly
// No need to actually visit the container element
this._traverse(containerEl);
} else {
// More than one top-level element, need to wrap the whole thing in a
// container.
this.output += this.config.indent + this.config.indent + this.config.indent;
this.level++;
this._visit(containerEl);
}
this.output = this.output.trim() + '\n';
if (this.config.createClass) {
this.output += this.config.indent + this.config.indent + ');\n';
this.output += this.config.indent + '}\n';
this.output += '});';
}
return this.output;
},
/**
* Cleans up the specified HTML so it's in a format acceptable for
* converting.
*
* @param {string} html HTML to clean
* @return {string} Cleaned HTML
*/
_cleanInput: function(html) {
// Remove unnecessary whitespace
html = html.trim();
// Ugly method to strip script tags. They can wreak havoc on the DOM nodes
// so let's not even put them in the DOM.
html = html.replace(/<script(.*?)<\/script>/g, '');
return html;
},
/**
* Determines if there's only one top-level node in the DOM tree. That is,
* all the HTML is wrapped by a single HTML tag.
*
* @param {DOMElement} containerEl Container element
* @return {boolean}
*/
_onlyOneTopLevel: function(containerEl) {
// Only a single child element
if (
containerEl.childNodes.length === 1
&& containerEl.childNodes[0].nodeType === NODE_TYPE.ELEMENT
) {
return true;
}
// Only one element, and all other children are whitespace
var foundElement = false;
for (var i = 0, count = containerEl.childNodes.length; i < count; i++) {
var child = containerEl.childNodes[i];
if (child.nodeType === NODE_TYPE.ELEMENT) {
if (foundElement) {
// Encountered an element after already encountering another one
// Therefore, more than one element at root level
return false;
} else {
foundElement = true;
}
} else if (child.nodeType === NODE_TYPE.TEXT && !isEmpty(child.textContent)) {
// Contains text content
return false;
}
}
return true;
},
/**
* Gets a newline followed by the correct indentation for the current
* nesting level
*
* @return {string}
*/
_getIndentedNewline: function() {
return '\n' + repeatString(this.config.indent, this.level + 2);
},
/**
* Handles processing the specified node
*
* @param {Node} node
*/
_visit: function(node) {
this._beginVisit(node);
this._traverse(node);
this._endVisit(node);
},
/**
* Traverses all the children of the specified node
*
* @param {Node} node
*/
_traverse: function(node) {
this.level++;
for (var i = 0, count = node.childNodes.length; i < count; i++) {
this._visit(node.childNodes[i]);
}
this.level--;
},
/**
* Handle pre-visit behaviour for the specified node.
*
* @param {Node} node
*/
_beginVisit: function(node) {
switch (node.nodeType) {
case NODE_TYPE.ELEMENT:
this._beginVisitElement(node);
break;
case NODE_TYPE.TEXT:
this._visitText(node);
break;
case NODE_TYPE.COMMENT:
this._visitComment(node);
break;
default:
console.warn('Unrecognised node type: ' + node.nodeType);
}
},
/**
* Handles post-visit behaviour for the specified node.
*
* @param {Node} node
*/
_endVisit: function(node) {
switch (node.nodeType) {
case NODE_TYPE.ELEMENT:
this._endVisitElement(node);
break;
// No ending tags required for these types
case NODE_TYPE.TEXT:
case NODE_TYPE.COMMENT:
break;
}
},
/**
* Handles pre-visit behaviour for the specified element node
*
* @param {DOMElement} node
*/
_beginVisitElement: function(node) {
var tagName = node.tagName.toLowerCase();
var attributes = [];
for (var i = 0, count = node.attributes.length; i < count; i++) {
attributes.push(this._getElementAttribute(node, node.attributes[i]));
}
this.output += '<' + tagName;
if (attributes.length > 0) {
this.output += ' ' + attributes.join(' ');
}
if (node.firstChild) {
this.output += '>';
}
},
/**
* Handles post-visit behaviour for the specified element node
*
* @param {Node} node
*/
_endVisitElement: function(node) {
// De-indent a bit
// TODO: It's inefficient to do it this way :/
this.output = trimEnd(this.output, this.config.indent);
if (node.firstChild) {
this.output += '</' + node.tagName.toLowerCase() + '>';
} else {
this.output += ' />';
}
},
/**
* Handles processing of the specified text node
*
* @param {TextNode} node
*/
_visitText: function(node) {
var text = node.textContent;
// If there's a newline in the text, adjust the indent level
if (text.indexOf('\n') > -1) {
text = node.textContent.replace(/\n\s*/g, this._getIndentedNewline());
}
this.output += text;
},
/**
* Handles processing of the specified text node
*
* @param {Text} node
*/
_visitComment: function(node) {
// Do not render the comment
// Since we remove comments, we also need to remove the next line break so we
// don't end up with extra whitespace after every comment
//if (node.nextSibling && node.nextSibling.nodeType === NODE_TYPE.TEXT) {
// node.nextSibling.textContent = node.nextSibling.textContent.replace(/\n\s*/, '');
//}
this.output += '{/*' + node.textContent.replace('*/', '* /') + '*/}';
},
/**
* Gets a JSX formatted version of the specified attribute from the node
*
* @param {DOMElement} node
* @param {object} attribute
* @return {string}
*/
_getElementAttribute: function(node, attribute) {
switch (attribute.name) {
case 'style':
return this._getStyleAttribute(attribute.value);
default:
var name = ATTRIBUTE_MAPPING[attribute.name] || attribute.name;
var result = name + '=';
// Numeric values should be output as {123} not "123"
if (isNumeric(attribute.value)) {
result += '{' + attribute.value + '}';
} else {
result += '"' + attribute.value.replace('"', '&quot;') + '"';
}
return result;
}
},
/**
* Gets a JSX formatted version of the specified element styles
*
* @param {string} styles
* @return {string}
*/
_getStyleAttribute: function(styles) {
var jsxStyles = new StyleParser(styles).toJSXString();
return 'style={{' + jsxStyles + '}}';
}
};
/**
* Handles parsing of inline styles
*
* @param {string} rawStyle Raw style attribute
* @constructor
*/
var StyleParser = function(rawStyle) {
this.parse(rawStyle);
};
StyleParser.prototype = {
/**
* Parse the specified inline style attribute value
* @param {string} rawStyle Raw style attribute
*/
parse: function(rawStyle) {
this.styles = {};
rawStyle.split(';').forEach(function(style) {
style = style.trim();
var firstColon = style.indexOf(':');
var key = style.substr(0, firstColon);
var value = style.substr(firstColon + 1).trim();
if (key !== '') {
this.styles[key] = value;
}
}, this);
},
/**
* Convert the style information represented by this parser into a JSX
* string
*
* @return {string}
*/
toJSXString: function() {
var output = [];
for (var key in this.styles) {
if (!this.styles.hasOwnProperty(key)) {
continue;
}
output.push(this.toJSXKey(key) + ': ' + this.toJSXValue(this.styles[key]));
}
return output.join(', ');
},
/**
* Convert the CSS style key to a JSX style key
*
* @param {string} key CSS style key
* @return {string} JSX style key
*/
toJSXKey: function(key) {
return hyphenToCamelCase(key);
},
/**
* Convert the CSS style value to a JSX style value
*
* @param {string} value CSS style value
* @return {string} JSX style value
*/
toJSXValue: function(value) {
if (isNumeric(value)) {
// If numeric, no quotes
return value;
} else if (endsWith(value, 'px')) {
// "500px" -> 500
return trimEnd(value, 'px');
} else {
// Proably a string, wrap it in quotes
return '\'' + value.replace(/'/g, '"') + '\'';
}
}
};
// Expose public API
global.HTMLtoJSX = HTMLtoJSX;
}(window));

89
docs/_js/html-jsx.js Normal file
View File

@@ -0,0 +1,89 @@
/**
* Copyright 2013-2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @jsx React.DOM
*/
/**
* This is a web interface for the HTML to JSX converter contained in
* `html-jsx-lib.js`.
*/
;(function() {
var HELLO_COMPONENT = "\
<!-- Hello world -->\n\
<div class=\"awesome\" style=\"border: 1px solid red\">\n\
<label for=\"name\">Enter your name: </label>\n\
<input type=\"text\" id=\"name\" />\n\
</div>\n\
<p>Enter your HTML here</p>\
";
var HTMLtoJSXComponent = React.createClass({
getInitialState: function() {
return {
outputClassName: 'NewComponent',
createClass: true
};
},
onReactClassNameChange: function(evt) {
this.setState({ outputClassName: evt.target.value });
},
onCreateClassChange: function(evt) {
this.setState({ createClass: evt.target.checked });
},
setInput: function(input) {
this.setState({ input: input });
this.convertToJsx();
},
convertToJSX: function(input) {
var converter = new HTMLtoJSX({
outputClassName: this.state.outputClassName,
createClass: this.state.createClass
});
return converter.convert(input);
},
render: function() {
return (
<div>
<div id="options">
<label>
<input
type="checkbox"
checked={this.state.createClass}
onChange={this.onCreateClassChange} />
Create class
</label>
<label style={{display: this.state.createClass ? '' : 'none'}}>
·
Class name:
<input
type="text"
value={this.state.outputClassName}
onChange={this.onReactClassNameChange} />
</label>
</div>
<ReactPlayground
codeText={HELLO_COMPONENT}
renderCode={true}
transformer={this.convertToJSX}
/>
</div>
);
}
});
React.renderComponent(<HTMLtoJSXComponent />, document.getElementById('jsxCompiler'));
}());

8
docs/_js/html5shiv.min.js vendored Normal file
View File

@@ -0,0 +1,8 @@
/*
HTML5 Shiv v3.6.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
(function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x<style>article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}</style>";
c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="<xyz></xyz>";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
"undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup main mark meter nav output progress section summary time video",version:"3.6.2",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment();
for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);

View File

@@ -6,14 +6,22 @@ var HELLO_COMPONENT = "\
/** @jsx React.DOM */\n\
var HelloMessage = React.createClass({\n\
render: function() {\n\
return <div>{'Hello ' + this.props.name}</div>;\n\
return <div>Hello {this.props.name}</div>;\n\
}\n\
});\n\
\n\
React.renderComponent(<HelloMessage name=\"John\" />, mountNode);\
";
var transformer = function(code) {
return JSXTransformer.transform(code).code;
}
React.renderComponent(
<ReactPlayground codeText={HELLO_COMPONENT} renderCode={true} />,
<ReactPlayground
codeText={HELLO_COMPONENT}
renderCode={true}
transformer={transformer}
showCompiledJSTab={false}
/>,
document.getElementById('jsxCompiler')
);

View File

@@ -14,25 +14,33 @@ var IS_MOBILE = (
);
var CodeMirrorEditor = React.createClass({
componentDidMount: function(root) {
if (IS_MOBILE) {
return;
}
componentDidMount: function() {
if (IS_MOBILE) return;
this.editor = CodeMirror.fromTextArea(this.refs.editor.getDOMNode(), {
mode: 'javascript',
lineNumbers: false,
lineWrapping: true,
smartIndent: false, // javascript mode does bad things with jsx indents
matchBrackets: true,
theme: 'solarized-light'
theme: 'solarized-light',
readOnly: this.props.readOnly
});
this.editor.on('change', this.onChange);
this.onChange();
this.editor.on('change', this.handleChange);
},
onChange: function() {
if (this.props.onChange) {
var content = this.editor.getValue();
this.props.onChange(content);
componentDidUpdate: function() {
if (this.props.readOnly) {
this.editor.setValue(this.props.codeText);
}
},
handleChange: function() {
if (!this.props.readOnly) {
this.props.onChange && this.props.onChange(this.editor.getValue());
}
},
render: function() {
// wrap in a div to fully contain CodeMirror
var editor;
@@ -44,87 +52,159 @@ var CodeMirrorEditor = React.createClass({
}
return (
<div class={this.props.className}>
<div style={this.props.style} className={this.props.className}>
{editor}
</div>
);
}
});
var selfCleaningTimeout = {
componentDidUpdate: function() {
clearTimeout(this.timeoutID);
},
setTimeout: function() {
clearTimeout(this.timeoutID);
this.timeoutID = setTimeout.apply(null, arguments);
}
};
var ReactPlayground = React.createClass({
MODES: {XJS: 'XJS', JS: 'JS'}, //keyMirror({XJS: true, JS: true}),
mixins: [selfCleaningTimeout],
MODES: {JSX: 'JSX', JS: 'JS'}, //keyMirror({JSX: true, JS: true}),
propTypes: {
codeText: React.PropTypes.string.isRequired,
transformer: React.PropTypes.func,
renderCode: React.PropTypes.bool,
},
getDefaultProps: function() {
return {
transformer: function(code) {
return JSXTransformer.transform(code).code;
},
showCompiledJSTab: true
};
},
getInitialState: function() {
return {mode: this.MODES.XJS, code: this.props.codeText};
return {
mode: this.MODES.JSX,
code: this.props.codeText,
};
},
bindState: function(name) {
return function(value) {
var newState = {};
newState[name] = value;
this.setState(newState);
}.bind(this);
handleCodeChange: function(value) {
this.setState({code: value});
this.executeCode();
},
getDesugaredCode: function() {
return JSXTransformer.transform(this.state.code).code;
handleCodeModeSwitch: function(mode) {
this.setState({mode: mode});
},
compileCode: function() {
return this.props.transformer(this.state.code);
},
render: function() {
var content;
if (this.state.mode === this.MODES.XJS) {
content =
<CodeMirrorEditor
onChange={this.bindState('code')}
class="playgroundStage"
codeText={this.state.code}
/>;
} else if (this.state.mode === this.MODES.JS) {
content =
<div class="playgroundJS playgroundStage">
{this.getDesugaredCode()}
</div>;
}
var isJS = this.state.mode === this.MODES.JS;
var compiledCode = '';
try {
compiledCode = this.compileCode();
} catch (err) {}
var JSContent =
<CodeMirrorEditor
key="js"
className="playgroundStage CodeMirror-readonly"
onChange={this.handleCodeChange}
codeText={compiledCode}
readOnly={true}
/>;
var JSXContent =
<CodeMirrorEditor
key="jsx"
onChange={this.handleCodeChange}
className="playgroundStage"
codeText={this.state.code}
/>;
var JSXTabClassName =
'playground-tab' + (isJS ? '' : ' playground-tab-active');
var JSTabClassName =
'playground-tab' + (isJS ? ' playground-tab-active' : '');
var JSTab =
<div
className={JSTabClassName}
onClick={this.handleCodeModeSwitch.bind(this, this.MODES.JS)}>
Compiled JS
</div>;
var JSXTab =
<div
className={JSXTabClassName}
onClick={this.handleCodeModeSwitch.bind(this, this.MODES.JSX)}>
Live JSX Editor
</div>
return (
<div class="playground">
<div class="playgroundCode">
{content}
<div className="playground">
<div>
{JSXTab}
{this.props.showCompiledJSTab && JSTab}
</div>
<div class="playgroundPreview">
<div className="playgroundCode">
{isJS ? JSContent : JSXContent}
</div>
<div className="playgroundPreview">
<div ref="mount" />
</div>
</div>
);
},
componentDidMount: function() {
this.executeCode();
},
componentDidUpdate: function() {
this.executeCode();
componentWillUpdate: function(nextProps, nextState) {
// execute code only when the state's not being updated by switching tab
// this avoids re-displaying the error, which comes after a certain delay
if (this.state.code !== nextState.code) {
this.executeCode();
}
},
executeCode: function() {
var mountNode = this.refs.mount.getDOMNode();
try {
React.unmountAndReleaseReactRootNode(mountNode);
React.unmountComponentAtNode(mountNode);
} catch (e) { }
try {
var compiledCode = this.compileCode();
if (this.props.renderCode) {
React.renderComponent(
<pre>{this.getDesugaredCode()}</pre>,
<CodeMirrorEditor codeText={compiledCode} readOnly={true} />,
mountNode
);
} else {
eval(this.getDesugaredCode());
eval(compiledCode);
}
} catch (e) {
React.renderComponent(
<div content={e.toString()} class="playgroundError" />,
mountNode
);
} catch (err) {
this.setTimeout(function() {
React.renderComponent(
<div className="playgroundError">{err.toString()}</div>,
mountNode
);
}, 500);
}
}
});

View File

@@ -1,4 +1,5 @@
<!DOCTYPE html>
<!--[if IE]><![endif]-->
<html>
<head>
<meta charset="utf-8">
@@ -15,13 +16,18 @@
<link rel="shortcut icon" href="/react/favicon.ico">
<link rel="alternate" type="application/rss+xml" title="{{ site.name }}" href="{{ site.url }}{{ site.baseurl }}/feed.xml">
<link rel="stylesheet" href="/react/css/react.css">
<link rel="stylesheet" href="/react/css/syntax.css">
<link rel="stylesheet" href="/react/css/codemirror.css">
<link rel="stylesheet" href="/react/css/react.css">
<script type="text/javascript" src="//use.typekit.net/vqa1hcx.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
<!--[if lte IE 8]>
<script type="text/javascript" src="/react/js/html5shiv.min.js"></script>
<script type="text/javascript" src="/react/js/es5-shim.min.js"></script>
<script type="text/javascript" src="/react/js/es5-sham.min.js"></script>
<![endif]-->
<script type="text/javascript" src="/react/js/codemirror.js"></script>
<script type="text/javascript" src="/react/js/javascript.js"></script>
<script type="text/javascript" src="/react/js/react.min.js"></script>
@@ -40,13 +46,12 @@
React
</a>
<ul class="nav-site">
<li><a href="/react/docs/getting-started.html"{% if page.sectionid == 'docs' %} class="active"{% endif %}>docs</a></li>
<li><a href="/react/docs/getting-started.html"{% if page.sectionid == 'docs' or page.sectionid == 'tips' %} class="active"{% endif %}>docs</a></li>
<li><a href="/react/support.html"{% if page.id == 'support' %} class="active"{% endif %}>support</a></li>
<li><a href="/react/downloads.html"{% if page.id == 'downloads' %} class="active"{% endif %}>download</a></li>
<li><a href="/react/blog/"{% if page.sectionid == 'blog' %} class="active"{% endif %}>blog</a></li>
<li><a href="http://github.com/facebook/react">github</a>
</ul>
<!-- <iframe src="http://ghbtns.com/github&#45;btn.html?user=facebook&#38;repo=react.js&#38;type=fork"allowtransparency="true" frameborder="0" scrolling="0" width="62" height="20"></iframe> -->
</div>
</div>
@@ -69,11 +74,15 @@
{{ content }}
<footer class="wrap">
<div class="left">A Facebook &amp; Instagram collaboration.</div>
<div class="right">&copy; 2013 Facebook Inc.</div>
<div class="left">
A Facebook &amp; Instagram collaboration.<br>
<a href="/react/acknowledgements.html">Acknowledgements</a>
</div>
<div class="right">&copy; 2014 Facebook Inc.</div>
</footer>
</div>
<div id="fb-root"></div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

25
docs/_layouts/tips.html Normal file
View File

@@ -0,0 +1,25 @@
---
layout: default
sectionid: tips
---
<section class="content wrap documentationContent">
{% include nav_docs.html %}
<div class="inner-content">
<h1>{{ page.title }}</h1>
<div class="subHeader">{{ page.description }}</div>
{{ content }}
<div class="docs-prevnext">
{% if page.prev %}
<a class="docs-prev" href="/react/tips/{{ page.prev }}">&larr; Prev</a>
{% endif %}
{% if page.next %}
<a class="docs-next" href="/react/tips/{{ page.next }}">Next &rarr;</a>
{% endif %}
</div>
<div class="fb-comments" data-width="650" data-num-posts="10" data-href="{{ site.url }}{{ site.baseurl }}{{ page.url }}"></div>
</div>
</section>

View File

@@ -11,7 +11,7 @@ class Redcarpet::Render::HTML
.gsub(/\s+/, "-")
.gsub(/[^A-Za-z0-9\-_.]/, "")
return "<h#{level} id=\"#{clean_title}\">#{title}</h#{level}>"
return "<h#{level}><a class=\"anchor\" name=\"#{clean_title}\"></a>#{title} <a class=\"hash-link\" href=\"##{clean_title}\">#</a></h#{level}>"
end
end

View File

@@ -31,8 +31,8 @@ to render views, which we see as an advantage over templates for a few reasons:
**no manual string concatenation** and therefore less surface area for XSS
vulnerabilities.
We've also created [JSX](http://facebook.github.io/react/docs/syntax.html), an optional
syntax extension, in case you prefer the readability of HTML to raw JavaScript.
We've also created [JSX](/react/docs/jsx-in-depth.html), an optional syntax
extension, in case you prefer the readability of HTML to raw JavaScript.
## Reactive updates are dead simple.
@@ -41,7 +41,7 @@ React really shines when your data changes over time.
In a traditional JavaScript application, you need to look at what data changed
and imperatively make changes to the DOM to keep it up-to-date. Even AngularJS,
which provides a declarative interface via directives and data binding [requires
a linking function to manually update DOM nodes](http://docs.angularjs.org/guide/directive#reasonsbehindthecompilelinkseparation).
a linking function to manually update DOM nodes](http://code.angularjs.org/1.0.8/docs/guide/directive#reasonsbehindthecompilelinkseparation).
React takes a different approach.
@@ -81,11 +81,9 @@ some pretty cool things with it:
(including IE8) and automatically use
[event delegation](http://davidwalsh.name/event-delegate).
Head on over to
[facebook.github.io/react](http://facebook.github.io/react) to check
out what we have built. Our documentation is geared towards building
apps with the framework, but if you are interested in the
nuts and bolts
[get in touch](http://facebook.github.io/react/support.html) with us!
Head on over to [facebook.github.io/react](/react) to check out what we have
built. Our documentation is geared towards building apps with the framework,
but if you are interested in the nuts and bolts
[get in touch](/react/support.html) with us!
Thanks for reading!

View File

@@ -0,0 +1,52 @@
---
title: "React v0.5"
layout: post
author: Paul O'Shannessy
---
This release is the result of several months of hard work from members of the team and the community. While there are no groundbreaking changes in core, we've worked hard to improve performance and memory usage. We've also worked hard to make sure we are being consistent in our usage of DOM properties.
The biggest change you'll notice as a developer is that we no longer support `class` in JSX as a way to provide CSS classes. Since this prop was being converted to `className` at the transform step, it caused some confusion when trying to access it in composite components. As a result we decided to make our DOM properties mirror their counterparts in the JS DOM API. There are [a few exceptions](https://github.com/facebook/react/blob/master/src/dom/DefaultDOMPropertyConfig.js#L156) where we deviate slightly in an attempt to be consistent internally.
The other major change in v0.5 is that we've added an additional build - `react-with-addons` - which adds support for some extras that we've been working on including animations and two-way binding. [Read more about these addons in the docs](/react/docs/addons.html).
## Thanks to Our Community
We added *22 new people* to the list of authors since we launched React v0.4.1 nearly 3 months ago. With a total of 48 names in our `AUTHORS` file, that means we've nearly doubled the number of contributors in that time period. We've seen the number of people contributing to discussion on IRC, mailing lists, Stack Overflow, and GitHub continue rising. We've also had people tell us about talks they've given in their local community about React.
It's been awesome to see the things that people are building with React, and we can't wait to see what you come up with next!
## Changelog
### React
* Memory usage improvements - reduced allocations in core which will help with GC pauses
* Performance improvements - in addition to speeding things up, we made some tweaks to stay out of slow path code in V8 and Nitro.
* Standardized prop -> DOM attribute process. This previously resulting in additional type checking and overhead as well as confusing cases for users. Now we will always convert your value to a string before inserting it into the DOM.
* Support for Selection events.
* Support for [Composition events](https://developer.mozilla.org/en-US/docs/Web/API/CompositionEvent).
* Support for additional DOM properties (`charSet`, `content`, `form`, `httpEquiv`, `rowSpan`, `autoCapitalize`).
* Support for additional SVG properties (`rx`, `ry`).
* Support for using `getInitialState` and `getDefaultProps` in mixins.
* Support mounting into iframes.
* Bug fixes for controlled form components.
* Bug fixes for SVG element creation.
* Added `React.version`.
* Added `React.isValidClass` - Used to determine if a value is a valid component constructor.
* Removed `React.autoBind` - This was deprecated in v0.4 and now properly removed.
* Renamed `React.unmountAndReleaseReactRootNode` to `React.unmountComponentAtNode`.
* Began laying down work for refined performance analysis.
* Better support for server-side rendering - [react-page](https://github.com/facebook/react-page) has helped improve the stability for server-side rendering.
* Made it possible to use React in environments enforcing a strict [Content Security Policy](https://developer.mozilla.org/en-US/docs/Security/CSP/Introducing_Content_Security_Policy). This also makes it possible to use React to build Chrome extensions.
### React with Addons (New!)
* Introduced a separate build with several "addons" which we think can help improve the React experience. We plan to deprecate this in the long-term, instead shipping each as standalone pieces. [Read more in the docs](/react/docs/addons.html).
### JSX
* No longer transform `class` to `className` as part of the transform! This is a breaking change - if you were using `class`, you *must* change this to `className` or your components will be visually broken.
* Added warnings to the in-browser transformer to make it clear it is not intended for production use.
* Improved compatibility for Windows
* Improved support for maintaining line numbers when transforming.

View File

@@ -0,0 +1,25 @@
---
title: "React v0.5.1"
layout: post
author: Paul O'Shannessy
---
This release focuses on fixing some small bugs that have been uncovered over the past two weeks. I would like to thank everybody involved, specifically members of the community who fixed half of the issues found. Thanks to [Ben Alpert][1], [Andrey Popp][2], and [Laurence Rowe][3] for their contributions!
## Changelog
### React
* Fixed bug with `<input type="range">` and selection events.
* Fixed bug with selection and focus.
* Made it possible to unmount components from the document root.
* Fixed bug for `disabled` attribute handling on non-`<input>` elements.
### React with Addons
* Fixed bug with transition and animation event detection.
[1]: https://github.com/spicyj
[2]: https://github.com/andreypopp
[3]: https://github.com/lrowe

View File

@@ -0,0 +1,143 @@
---
title: "Thinking in React"
layout: post
author: Pete Hunt
---
React is, in my opinion, the premier way to build big, fast Web apps with JavaScript. It's scaled very well for us at Facebook and Instagram.
One of the many great parts of React is how it makes you think about apps as you build them. In this post I'll walk you through the thought process of building a searchable product data table using React.
## Start with a mock
Imagine that we already have a JSON API and a mock from our designer. Our designer apparently isn't very good because the mock looks like this:
![Mockup](/react/img/blog/thinking-in-react-mock.png)
Our JSON API returns some data that looks like this:
```
[
{category: "Sporting Goods", price: "$49.99", stocked: true, name: "Football"},
{category: "Sporting Goods", price: "$9.99", stocked: true, name: "Baseball"},
{category: "Sporting Goods", price: "$29.99", stocked: false, name: "Basketball"},
{category: "Electronics", price: "$99.99", stocked: true, name: "iPod Touch"},
{category: "Electronics", price: "$399.99", stocked: false, name: "iPhone 5"},
{category: "Electronics", price: "$199.99", stocked: true, name: "Nexus 7"}
];
```
## Step 1: break the UI into a component hierarchy
The first thing you'll want to do is to draw boxes around every component (and subcomponent) in the mock and give them all names. If you're working with a designer they may have already done this, so go talk to them! Their Photoshop layer names may end up being the names of your React components!
But how do you know what should be its own component? Just use the same techniques for deciding if you should create a new function or object. One such technique is the [single responsibility principle](http://en.wikipedia.org/wiki/Single_responsibility_principle), that is, a component should ideally only do one thing. If it ends up growing it should be decomposed into smaller subcomponents.
Since you're often displaying a JSON data model to a user, you'll find that if your model was built correctly your UI (and therefore your component structure) will map nicely onto it. That's because user interfaces and data models tend to adhere to the same *information architecture* which means the work of separating your UI into components is often trivial. Just break it up into components that represent exactly one piece of your data model.
![Component diagram](/react/img/blog/thinking-in-react-components.png)
You'll see here that we have five components in our simple app. I've italicized the data each component represents.
1. **`FilterableProductTable` (orange):** contains the entirety of the example
2. **`SearchBar` (blue):** receives all *user input*
3. **`ProductTable` (green):** displays and filters the *data collection* based on *user input*
4. **`ProductCategoryRow` (turquoise):** displays a heading for each *category*
5. **`ProductRow` (red):** displays a row for each *product*
If you look at `ProductTable` you'll see that the table header (containing the "Name" and "Price" labels) isn't its own component. This is a matter of preference and there's an argument to be made either way. For this example I left it as part of `ProductTable` because it is part of rendering the *data collection* which is `ProductTable`'s responsibility. However if this header grows to be complex (i.e. if we were to add affordances for sorting) it would certainly make sense to make this its own `ProductTableHeader` component.
Now that we've identified the components in our mock, let's arrange them into a hierarchy. This is easy. Components that appear within another component in the mock should appear as a child in the hierarchy:
* `FilterableProductTable`
* `SearchBar`
* `ProductTable`
* `ProductCategoryRow`
* `ProductRow`
## Step 2: Build a static version in React
<iframe width="100%" height="300" src="http://jsfiddle.net/6wQMG/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
Now that you have your component hierarchy it's time to start implementing your app. The easiest way is to build a version that takes your data model and renders the UI but has no interactivity. It's easiest to decouple these processes because building a static version requires a lot of typing and no thinking, and adding interactivity requires a lot of thinking and not a lot of typing. We'll see why.
To build a static version of your app that renders your data model you'll want to build components that reuse other components and pass data using *props*. *props* are a way of passing data from parent to child. If you're familiar with the concept of *state*, **don't use state at all** to build this static version. State is reserved only for interactivity, that is, data that changes over time. Since this is a static version of the app you don't need it.
You can build top-down or bottom-up. That is, you can either start with building the components higher up in the hierarchy (i.e. starting with `FilterableProductTable`) or with the ones lower in it (`ProductRow`). In simpler examples it's usually easier to go top-down and on larger projects it's easier to go bottom-up and write tests as you build.
At the end of this step you'll have a library of reusable components that render your data model. The components will only have `render()` methods since this is a static version of your app. The component at the top of the hierarchy (`FilterableProductTable`) will take your data model as a prop. If you make a change to your underlying data model and call `renderComponent()` again the UI will be updated. It's easy to see how your UI is updated and where to make changes since there's nothing complicated going on since React's **one-way data flow** (also called *one-way binding*) keeps everything modular, easy to reason about, and fast.
Simply refer to the [React docs](http://facebook.github.io/react/docs/) if you need help executing this step.
### A brief interlude: props vs state
There are two types of "model" data in React: props and state. It's important to understand the distinction between the two; skim [the official React docs](http://facebook.github.io/react/docs/interactivity-and-dynamic-uis.html) if you aren't sure what the difference is.
## Step 3: Identify the minimal (but complete) representation of UI state
To make your UI interactive you need to be able to trigger changes to your underlying data model. React makes this easy with **state**.
To build your app correctly you first need to think of the minimal set of mutable state that your app needs. The key here is DRY: *Don't Repeat Yourself*. Figure out what the absolute minimal representation of the state of your application needs to be and compute everything else you need on-demand. For example, if you're building a TODO list, just keep an array of the TODO items around; don't keep a separate state variable for the count. Instead, when you want to render the TODO count simply take the length of the TODO items array.
Think of all of the pieces of data in our example application. We have:
* The original list of products
* The search text the user has entered
* The value of the checkbox
* The filtered list of products
Let's go through each one and figure out which one is state. Simply ask three questions about each piece of data:
1. Is it passed in from a parent via props? If so, it probably isn't state.
2. Does it change over time? If not, it probably isn't state.
3. Can you compute it based on any other state or props in your component? If so, it's not state.
The original list of products is passed in as props, so that's not state. The search text and the checkbox seem to be state since they change over time and can't be computed from anything. And finally, the filtered list of products isn't state because it can be computed by combining the original list of products with the search text and value of the checkbox.
So finally, our state is:
* The search text the user has entered
* The value of the checkbox
## Step 4: Identify where your state should live
<iframe width="100%" height="300" src="http://jsfiddle.net/QvHnx/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
OK, so we've identified what the minimal set of app state is. Next we need to identify which component mutates, or *owns*, this state.
Remember: React is all about one-way data flow down the component hierarchy. It may not be immediately clear which component should own what state. **This is often the most challenging part for newcomers to understand,** so follow these steps to figure it out:
For each piece of state in your application:
* Identify every component that renders something based on that state.
* Find a common owner component (a single component above all the components that need the state in the hierarchy).
* Either the common owner or another component higher up in the hierarchy should own the state.
* If you can't find a component where it makes sense to own the state, create a new component simply for holding the state and add it somewhere in the hierarchy above the common owner component.
Let's run through this strategy for our application:
* `ProductTable` needs to filter the product list based on state and `SearchBar` needs to display the search text and checked state.
* The common owner component is `FilterableProductTable`.
* It conceptually makes sense for the filter text and checked value to live in `FilterableProductTable`
Cool, so we've decided that our state lives in `FilterableProductTable`. First, add a `getInitialState()` method to `FilterableProductTable` that returns `{filterText: '', inStockOnly: false}` to reflect the initial state of your application. Then pass `filterText` and `inStockOnly` to `ProductTable` and `SearchBar` as a prop. Finally, use these props to filter the rows in `ProductTable` and set the values of the form fields in `SearchBar`.
You can start seeing how your application will behave: set `filterText` to `"ball"` and refresh your app. You'll see the data table is updated correctly.
## Step 5: Add inverse data flow
<iframe width="100%" height="300" src="http://jsfiddle.net/3Vs3Q/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
So far we've built an app that renders correctly as a function of props and state flowing down the hierarchy. Now it's time to support data flowing the other way: the form components deep in the hierarchy need to update the state in `FilterableProductTable`.
React makes this data flow explicit to make it easy to understand how your program works, but it does require a little more typing than traditional two-way data binding. React provides an add-on called `ReactLink` to make this pattern as convenient as two-way binding, but for the purpose of this post we'll keep everything explicit.
If you try to type or check the box in the current version of the example you'll see that React ignores your input. This is intentional, as we've set the `value` prop of the `input` to always be equal to the `state` passed in from `FilterableProductTable`.
Let's think about what we want to happen. We want to make sure that whenever the user changes the form we update the state to reflect the user input. Since components should only update their own state, `FilterableProductTable` will pass a callback to `SearchBar` that will fire whenever the state should be updated. We can use the `onChange` event on the inputs to be notified of it. And the callback passed by `FilterableProductTable` will call `setState()` and the app will be updated.
Though this sounds like a lot it's really just a few lines of code. And it's really explicit how your data is flowing throughout the app.
## And that's it
Hopefully this gives you an idea of how to think about building components and applications with React. While it may be a little more typing than you're used to, remember that code is read far more than it's written, and it's extremely easy to read this modular, explicit code. As you start to build large libraries of components you'll appreciate this explicitness and modularity, and with code reuse your lines of code will start to shrink :)

View File

@@ -0,0 +1,125 @@
---
title: "Community Round-up #10"
layout: post
author: Vjeux
---
This is the 10th round-up already and React has come quite far since it was open sourced. Almost all new web projects at Khan Academy, Facebook, and Instagram are being developed using React. React has been deployed in a variety of contexts: a Chrome extension, a Windows 8 application, mobile websites, and desktop websites supporting Internet Explorer 8! Language-wise, React is not only being used within JavaScript but also CoffeeScript and ClojureScript.
The best part is that no drastic changes have been required to support all those use cases. Most of the efforts were targeted at polishing edge cases, performance improvements, and documentation.
## Khan Academy - Officially moving to React
[Joel Burget](http://joelburget.com/) announced at Hack Reactor that new front-end code at Khan Academy should be written in React!
> How did we get the rest of the team to adopt React? Using interns as an attack vector! Most full-time devs had already been working on their existing projects for a while and weren't looking to try something new at the time, but our class of summer interns was just arriving. For whatever reason, a lot of them decided to try React for their projects. Then mentors became exposed through code reviews or otherwise touching the new code. In this way React knowledge diffused to almost the whole team over the summer.
>
> Since the first React checkin on June 5, we've somehow managed to accumulate 23500 lines of jsx (React-flavored js) code. Which is terrifying in a way - that's a lot of code - but also really exciting that it was picked up so quickly.
>
> We held three meetings about how we should proceed with React. At the first two we decided to continue experimenting with React and deferred a final decision on whether to adopt it. At the third we adopted the policy that new code should be written in React.
>
> I'm excited that we were able to start nudging code quality forward. However, we still have a lot of work to do! One of the selling points of this transition is adopting a uniform frontend style. We're trying to upgrade all the code from (really old) pure jQuery and (regular old) Backbone views / Handlebars to shiny React. At the moment all we've done is introduce more fragmentation. We won't be gratuitously updating working code (if it ain't broke, don't fix it), but are seeking out parts of the codebase where we can shoot two birds with one stone by rewriting in React while fixing bugs or adding functionality.
>
> [Read the full article](http://joelburget.com/backbone-to-react/)
## React: Rethinking best practices
[Pete Hunt](http://www.petehunt.net/)'s talk at JSConf EU 2013 is now available in video.
<figure><iframe width="600" height="370" src="//www.youtube.com/embed/x7cQ3mrcKaY" frameborder="0" allowfullscreen></iframe></figure>
## Server-side React with PHP
[Stoyan Stefanov](http://www.phpied.com/)'s series of articles on React has two new entries on how to execute React on the server to generate the initial page load.
> This post is an initial hack to have React components render server-side in PHP.
>
> - Problem: Build web UIs
> - Solution: React
> - Problem: UI built in JS is anti-SEO (assuming search engines are still noscript) and bad for perceived performance (blank page till JS arrives)
> - Solution: [React page](https://github.com/facebook/react-page) to render the first view
> - Problem: Can't host node.js apps / I have tons of PHP code
> - Solution: Use PHP then!
>
> [**Read part 1 ...**](http://www.phpied.com/server-side-react-with-php/)
>
> [**Read part 2 ...**](http://www.phpied.com/server-side-react-with-php-part-2/)
>
> Rendered markup on the server:
> <figure>[![](/react/img/blog/react-php.png)](http://www.phpied.com/server-side-react-with-php-part-2/)</figure>
## TodoMVC Benchmarks
Webkit has a [TodoMVC Benchmark](https://github.com/WebKit/webkit/tree/master/PerformanceTests/DoYouEvenBench) that compares different frameworks. They recently included React and here are the results (average of 10 runs in Chrome 30):
- **AngularJS:** 4043ms
- **AngularJSPerf:** 3227ms
- **BackboneJS:** 1874ms
- **EmberJS:** 6822ms
- **jQuery:** 14628ms
- **React:** 2864ms
- **VanillaJS:** 5567ms
[Try it yourself!](http://www.petehunt.net/react/tastejs/benchmark.html)
Please don't take those numbers too seriously, they only reflect one very specific use case and are testing code that wasn't written with performance in mind.
Even though React scores as one of the fastest frameworks in the benchmark, the React code is simple and idiomatic. The only performance tweak used is the following function:
```javascript
/**
* This is a completely optional performance enhancement that you can implement
* on any React component. If you were to delete this method the app would still
* work correctly (and still be very performant!), we just use it as an example
* of how little code it takes to get an order of magnitude performance improvement.
*/
shouldComponentUpdate: function (nextProps, nextState) {
return (
nextProps.todo.id !== this.props.todo.id ||
nextProps.todo !== this.props.todo ||
nextProps.editing !== this.props.editing ||
nextState.editText !== this.state.editText
);
},
```
By default, React "re-renders" all the components when anything changes. This is usually fast enough that you don't need to care. However, you can provide a function that can tell whether there will be any change based on the previous and next states and props. If it is faster than re-rendering the component, then you get a performance improvement.
The fact that you can control when components are rendered is a very important characteristic of React as it gives you control over its performance. We are going to talk more about performance in the future, stay tuned.
## Guess the filter
[Connor McSheffrey](http://conr.me) implemented a small game using React. The goal is to guess which filter has been used to create the Instagram photo.
<figure>[![](/react/img/blog/guess_filter.jpg)](http://guessthefilter.com/)</figure>
## React vs FruitMachine
[Andrew Betts](http://trib.tv/), director of the [Financial Times Labs](http://labs.ft.com/), posted an article comparing [FruitMachine](https://github.com/ftlabs/fruitmachine) and React.
> Eerily similar, no? Maybe Facebook was inspired by Fruit Machine (after all, we got there first), but more likely, it just shows that this is a pretty decent way to solve the problem, and great minds think alike. We're graduating to a third phase in the evolution of web best practice - from intermingling of markup, style and behaviour, through a phase in which those concerns became ever more separated and encapsulated, and finally to a model where we can do that separation at a component level. Developments like Web Components show the direction the web community is moving, and frameworks like React and Fruit Machine are in fact not a lot more than polyfills for that promised behaviour to come.
>
> [Read the full article...](http://labs.ft.com/2013/10/client-side-layout-engines-react-vs-fruitmachine/)
Even though we weren't inspired by FruitMachine (React has been used in production since before FruitMachine was open sourced), it's great to see similar technologies emerging and becoming popular.
## React Brunch
[Matthew McCray](http://elucidata.net/) implemented [react-brunch](https://npmjs.org/package/react-brunch), a JSX compilation step for [Brunch](http://brunch.io/).
> Adds React support to brunch by automatically compiling `*.jsx` files.
>
> You can configure react-brunch to automatically insert a react header (`/** @jsx React.DOM */`) into all `*.jsx` files. Disabled by default.
>
> Install the plugin via npm with `npm install --save react-brunch`.
>
> [Read more...](https://npmjs.org/package/react-brunch)
## Random Tweet
I'm going to start adding a tweet at the end of each round-up. We'll start with this one:
<blockquote class="twitter-tweet"><p>This weekend <a href="https://twitter.com/search?q=%23angular&amp;src=hash">#angular</a> died for me. Meet new king <a href="https://twitter.com/search?q=%23reactjs&amp;src=hash">#reactjs</a></p>&mdash; Eldar Djafarov &#x30C3; (@edjafarov) <a href="https://twitter.com/edjafarov/statuses/397033796710961152">November 3, 2013</a></blockquote>

View File

@@ -0,0 +1,92 @@
---
title: "Community Round-up #11"
layout: post
author: Vjeux
---
This round-up is the proof that React has taken off from its Facebook's root: it features three in-depth presentations of React done by external people. This is awesome, keep them coming!
## Super VanJS 2013 Talk
[Steve Luscher](https://github.com/steveluscher) working at [LeanPub](https://leanpub.com/) made a 30 min talk at [Super VanJS](https://twitter.com/vanjs). He does a remarkable job at explaining why React is so fast with very exciting demos using the HTML5 Audio API.
<figure><iframe width="600" height="338" src="//www.youtube.com/embed/1OeXsL5mr4g" frameborder="0" allowfullscreen></iframe></figure>
## React Tips
[Connor McSheffrey](http://connormcsheffrey.com/) and [Cheng Lou](https://github.com/chenglou) added a new section to the documentation. It's a list of small tips that you will probably find useful while working on React. Since each article is very small and focused, we [encourage you to contribute](http://facebook.github.io/react/tips/introduction.html)!
- [Inline Styles](http://facebook.github.io/react/tips/inline-styles.html)
- [If-Else in JSX](http://facebook.github.io/react/tips/if-else-in-JSX.html)
- [Self-Closing Tag](http://facebook.github.io/react/tips/self-closing-tag.html)
- [Maximum Number of JSX Root Nodes](http://facebook.github.io/react/tips/maximum-number-of-jsx-root-nodes.html)
- [Shorthand for Specifying Pixel Values in style props](http://facebook.github.io/react/tips/style-props-value-px.html)
- [Type of the Children props](http://facebook.github.io/react/tips/children-props-type.html)
- [Value of null for Controlled Input](http://facebook.github.io/react/tips/controlled-input-null-value.html)
- [`componentWillReceiveProps` Not Triggered After Mounting](http://facebook.github.io/react/tips/componentWillReceiveProps-not-triggered-after-mounting.html)
- [Props in getInitialState Is an Anti-Pattern](http://facebook.github.io/react/tips/props-in-getInitialState-as-anti-pattern.html)
- [DOM Event Listeners in a Component](http://facebook.github.io/react/tips/dom-event-listeners.html)
- [Load Initial Data via AJAX](http://facebook.github.io/react/tips/initial-ajax.html)
- [False in JSX](http://facebook.github.io/react/tips/false-in-jsx.html)
## Intro to the React Framework
[Pavan Podila](http://blog.pixelingene.com/) wrote an in-depth introduction to React on TutsPlus. This is definitively worth reading.
> Within a component-tree, data should always flow down. A parent-component should set the props of a child-component to pass any data from the parent to the child. This is termed as the Owner-Owned pair. On the other hand user-events (mouse, keyboard, touches) will always bubble up from the child all the way to the root component, unless handled in between.
<figure>[![](/react/img/blog/tutsplus.png)](http://dev.tutsplus.com/tutorials/intro-to-the-react-framework--net-35660)</figure>
>
> [Read the full article ...](http://dev.tutsplus.com/tutorials/intro-to-the-react-framework--net-35660)
## 140-characters textarea
[Brian Kim](https://github.com/brainkim) wrote a small textarea component that gradually turns red as you reach the 140-characters limit. Because he only changes the background color, React is smart enough not to mess with the text selection.
<p data-height="178" data-theme-id="0" data-slug-hash="FECGb" data-user="brainkim" data-default-tab="result" class='codepen'>See the Pen <a href='http://codepen.io/brainkim/pen/FECGb'>FECGb</a> by Brian Kim (<a href='http://codepen.io/brainkim'>@brainkim</a>) on <a href='http://codepen.io'>CodePen</a></p>
<script async src="//codepen.io/assets/embed/ei.js"></script>
## Genesis Skeleton
[Eric Clemmons](http://ericclemmons.github.io/) is working on a "Modern, opinionated, full-stack starter kit for rapid, streamlined application development". The version 0.4.0 has just been released and has first-class support for React.
<figure>[![](/react/img/blog/genesis_skeleton.png)](http://genesis-skeleton.com/)</figure>
## AgFlow Talk
[Robert Zaremba](http://rz.scale-it.pl/) working on [AgFlow](http://www.agflow.com/) recently talked in Poland about React.
> In a nutshell, I presented why we chose React among other available options (ember.js, angular, backbone ...) in AgFlow, where Im leading an application development.
>
> During the talk a wanted to highlight that React is not about implementing a Model, but a way to construct visible components with some state. React is simple. It is super simple, you can learn it in 1h. On the other hand what is model? Which functionality it should provide? React does one thing and does it the best (for me)!
>
> [Read the full article...](http://rz.scale-it.pl/2013/10/20/frontend_components_in_react.html)
<figure><iframe src="https://docs.google.com/presentation/d/1JSFbjCuuexwOHCeHWBMNRIJdyfD2Z0ZQwX65WOWkfaI/embed?start=false" frameborder="0" width="600" height="468" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"> </iframe></figure>
## JSX
[Todd Kennedy](http://tck.io/) working at Cond&eacute; Nast wrote [JSXHint](https://github.com/CondeNast/JSXHint) and explains in a blog post his perspective on JSX.
> Lets start with the elephant in the room: JSX?
> Is this some sort of template language? Specifically no. This might have been the first big stumbling block. What looks like to be a templating language is actually an in-line DSL that gets transpiled directly into JavaScript by the JSX transpiler.
>
> Creating elements in memory is quick -- copying those elements into the DOM is where the slowness occurs. This is due to a variety of issues, most namely reflow/paint. Changing the items in the DOM causes the browser to re-paint the display, apply styles, etc. We want to keep those operations to an absolute minimum, especially if we're dealing with something that needs to update the DOM frequently.
>
> [Read the full article...](http://tck.io/posts/jsxhint_and_react.html)
## Photo Gallery
[Maykel Loomans](http://miekd.com/), designer at Instagram, wrote a gallery for photos he shot using React.
<figure>[![](/react/img/blog/xoxo2013.png)](http://photos.miekd.com/xoxo2013/)</figure>
## Random Tweet
<img src="/react/img/blog/steve_reverse.gif" style="float: right;" />
<div style="width: 320px;"><blockquote class="twitter-tweet"><p>I think this reversed gif of Steve Urkel best describes my changing emotions towards the React Lib <a href="http://t.co/JoX0XqSXX3">http://t.co/JoX0XqSXX3</a></p>&mdash; Ryan Seddon (@ryanseddon) <a href="https://twitter.com/ryanseddon/statuses/398572848802852864">November 7, 2013</a></blockquote></div>

View File

@@ -0,0 +1,23 @@
---
title: "React v0.5.2, v0.4.2"
layout: post
author: Paul O'Shannessy
---
Today we're releasing an update to address a potential XSS vulnerability that can arise when using user data as a `key`. Typically "safe" data is used for a `key`, for example, an id from your database, or a unique hash. However there are cases where it may be reasonable to use user generated content. A carefully crafted piece of content could result in arbitrary JS execution. While we make a very concerted effort to ensure all text is escaped before inserting it into the DOM, we missed one case. Immediately following the discovery of this vulnerability, we performed an audit to ensure we this was the only such vulnerability.
This only affects v0.5.x and v0.4.x. Versions in the 0.3.x family are unaffected.
Updated versions are available for immediate download via npm, bower, and on our [download page][download].
We take security very seriously at Facebook. For most of our products, users don't need to know that a security issue has been fixed. But with libraries like React, we need to make sure developers using React have access to fixes to keep their users safe.
While we've encouraged responsible disclosure as part of [Facebook's whitehat bounty program][bounty] since we launched, we don't have a good process for notifying our users. Hopefully we don't need to use it, but moving forward we'll set up a little bit more process to ensure the safety of our users. Ember.js has [an excellent policy][ember] which we may use as our model.
You can learn more about the vulnerability discussed here: [CVE-2013-7035][cve].
[download]: http://facebook.github.io/react/downloads.html
[bounty]: https://www.facebook.com/whitehat/
[ember]: http://emberjs.com/security/
[cve]: https://groups.google.com/forum/#!topic/reactjs/OIqxlB2aGfU

View File

@@ -0,0 +1,48 @@
---
title: "React v0.8"
layout: post
author: Paul O'Shannessy
---
I'll start by answering the obvious question:
> What happened to 0.6 and 0.7?
It's become increasingly obvious since our launch in May that people want to use React on the server. With the server-side rendering abilities, that's a perfect fit. However using the same copy of React on the server and then packaging it up for the client is surprisingly a harder problem. People have been using our `react-tools` module which includes React, but when browserifying that ends up packaging all of `esprima` and some other dependencies that aren't needed on the client. So we wanted to make this whole experience better.
We talked with [Jeff Barczewski][jeff] who was the owner of the `react` module on npm. He was kind enough to transition ownership to us and release his package under a different name: `autoflow`. I encourage you to [check it out][autoflow] if you're writing a lot of asynchronous code. In order to not break all of `react`'s current users of 0.7.x, we decided to bump our version to 0.8 and skip the issue entirely. We're also including a warning if you use our `react` module like you would use the previous package.
In order to make the transition to 0.8 for our current users as painless as possible, we decided to make 0.8 primarily a bug fix release on top of 0.5. No public APIs were changed (even if they were already marked as deprecated). We haven't added any of the new features we have in master, though we did take the opportunity to pull in some improvements to internals.
We hope that by releasing `react` on npm, we will enable a new set of uses that have been otherwise difficult. All feedback is welcome!
## Changelog
### React
* Added support for more attributes:
* `rows` & `cols` for `<textarea>`
* `defer` & `async` for `<script>`
* `loop` for `<audio>` & `<video>`
* `autoCorrect` for form fields (a non-standard attribute only supported by mobile WebKit)
* Improved error messages
* Fixed Selection events in IE11
* Added `onContextMenu` events
### React with Addons
* Fixed bugs with TransitionGroup when children were undefined
* Added support for `onTransition`
### react-tools
* Upgraded `jstransform` and `esprima-fb`
### JSXTransformer
* Added support for use in IE8
* Upgraded browserify, which reduced file size by ~65KB (16KB gzipped)
[jeff]: https://github.com/jeffbski
[autoflow]: https://github.com/jeffbski/autoflow

View File

@@ -0,0 +1,105 @@
---
title: "Community Round-up #12"
layout: post
author: Vjeux
---
React got featured on the front-page of Hacker News thanks to the Om library. If you try it out for the first time, take a look at the [docs](/react/docs/getting-started.html) and do not hesitate to ask questions on the [Google Group](http://groups.google.com/group/reactjs), [IRC](irc://chat.freenode.net/reactjs) or [Stack Overflow](http://stackoverflow.com/questions/tagged/reactjs). We are trying our best to help you out!
## The Future of Javascript MVC
[David Nolen](http://swannodette.github.io/) announced Om, a thin wrapper on-top of React in ClojureScript. It stands out by only using immutable data structures. This unlocks the ability to write a very efficient [shouldComponentUpdate](http://facebook.github.io/react/docs/component-specs.html#updating-shouldcomponentupdate) and get huge performance improvements on some tasks.
> We've known this for some time over here in the ClojureScript corner of the world - all of our collections are immutable and modeled directly on the original Clojure versions written in Java. Modern JavaScript engines have now been tuned to the point that it's no longer uncommon to see collection performance within 2.5X of the Java Virtual Machine.
>
> Wait, wait, wait. What does the performance of persistent data structures have to do with the future of JavaScript MVCs?
>
> A whole lot.
> <figure>[![](/react/img/blog/om-backbone.png)](http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/)</figure>
>
> [Read the full article...](http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/)
## Scroll Position with React
Managing the scroll position when new content is inserted is usually very tricky to get right. [Vjeux](http://blog.vjeux.com/) discovered that [componentWillUpdate](http://facebook.github.io/react/docs/component-specs.html#updating-componentwillupdate) and [componentDidUpdate](http://facebook.github.io/react/docs/component-specs.html#updating-componentdidupdate) were triggered exactly at the right time to manage the scroll position.
> We can check the scroll position before the component has updated with componentWillUpdate and scroll if necessary at componentDidUpdate
>
> ```
componentWillUpdate: function() {
var node = this.getDOMNode();
this.shouldScrollBottom =
(node.scrollTop + node.offsetHeight) === node.scrollHeight;
},
componentDidUpdate: function() {
if (this.shouldScrollBottom) {
var node = this.getDOMNode();
node.scrollTop = node.scrollHeight
}
},
```
>
> [Check out the blog article...](http://blog.vjeux.com/2013/javascript/scroll-position-with-react.html)
## Lights Out
React declarative approach is well suited to write games. [Cheng Lou](https://github.com/chenglou) wrote the famous Lights Out game in React. It's a good example of use of [TransitionGroup](http://facebook.github.io/react/docs/animation.html) to implement animations.
<figure>[![](/react/img/blog/lights-out.png)](http://chenglou.github.io/react-lights-out/)</figure>
[Try it out!](http://chenglou.github.io/react-lights-out/)
## Reactive Table Bookmarklet
[Stoyan Stefanov](http://www.phpied.com/) wrote a bookmarklet to process tables on the internet. It adds a little "pop" button that expands to a full-screen view with sorting, editing and export to csv and json.
<figure>[![](/react/img/blog/reactive-bookmarklet.png)](http://www.phpied.com/reactivetable-bookmarklet/)</figure>
[Check out the blog post...](http://www.phpied.com/reactivetable-bookmarklet/)
## MontageJS Tutorial in React
[Ross Allen](https://twitter.com/ssorallen) implemented [MontageJS](http://montagejs.org/)'s [Reddit tutorial](http://montagejs.org/docs/tutorial-reddit-client-with-montagejs.html) in React. This is a good opportunity to compare the philosophies of the two libraries.
<iframe width="100%" height="300" src="http://jsfiddle.net/ssorallen/fEsYt/embedded/result,html,js" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
[View the source on JSFiddle...](http://jsfiddle.net/ssorallen/fEsYt/)
## Writing Good React Components
[William Högman Rudenmalm](http://blog.whn.se/) wrote an article on how to write good React components. This is full of good advice.
> The idea of dividing software into smaller parts or components is hardly new - It is the essance of good software. The same principles that apply to software in general apply to building React components. That doesnt mean that writing good React components is just about applying general rules.
>
> The web offers a unique set of challenges, which React offers interesting solutions to. First and foremost among these solutions is the what is called the Mock DOM. Rather than having user code interface with the DOM in a direct fashion, as is the case with most DOM manipulation libraries.
>
> You build a model of how you want the DOM end up like. React then inserts this model into the DOM. This is very useful for updates because React simply compares the model or mock DOM against the actual DOM, and then only updates based on the difference between the two states.
>
> [Read the full article ...](http://blog.whn.se/post/69621609605/writing-good-react-components)
## Hoodie React TodoMVC
[Sven Lito](http://svenlito.com/) integrated the React TodoMVC example within an [Hoodie](http://hood.ie/) web app environment. This should let you get started using Hoodie and React.
```
hoodie new todomvc -t "hoodiehq/hoodie-react-todomvc"
```
[Check out on GitHub...](https://github.com/hoodiehq/hoodie-react-todomvc)
## JSX Compiler
Ever wanted to have a quick way to see what a JSX tag would be converted to? [Tim Yung](http://www.yungsters.com/) made a page for it.
<figure>[![](/react/img/blog/jsx-compiler.png)](http://facebook.github.io/react/jsx-compiler.html)</figure>
[Try it out!](http://facebook.github.io/react/jsx-compiler.html)
## Random Tweet
<center><blockquote class="twitter-tweet" lang="en"><p>.<a href="https://twitter.com/jordwalke">@jordwalke</a> lays down some truth <a href="http://t.co/AXAn0UlUe3">http://t.co/AXAn0UlUe3</a>, optimizing your JS application shouldn&#39;t force you to rewrite so much code <a href="https://twitter.com/search?q=%23reactjs&amp;src=hash">#reactjs</a></p>&mdash; David Nolen (@swannodette) <a href="https://twitter.com/swannodette/statuses/413780079249215488">December 19, 2013</a></blockquote></center>

View File

@@ -0,0 +1,119 @@
---
title: "Community Round-up #13"
layout: post
author: Vjeux
---
Happy holidays! This blog post is a little-late Christmas present for all the React users. Hopefully it will inspire you to write awesome web apps in 2014!
## React Touch
[Pete Hunt](http://www.petehunt.net/) wrote three demos showing that React can be used to run 60fps native-like experiences on mobile web. A frosted glass effect, an image gallery with 3d animations and an infinite scroll view.
<figure><iframe src="//player.vimeo.com/video/79659941" width="220" height="400" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></figure>
[Try out the demos!](http://petehunt.github.io/react-touch/)
## Introduction to React
[Stoyan Stefanov](http://www.phpied.com/) talked at Joe Dev On Tech about React. He goes over all the features of the library and ends with a concrete example.
<figure><iframe width="560" height="315" src="//www.youtube.com/embed/SMMRJif5QW0" frameborder="0" allowfullscreen></iframe></figure>
## JSX: E4X The Good Parts
JSX is often compared to the now defunct E4X, [Vjeux](http://blog.vjeux.com/) went over all the E4X features and explained how JSX is different and hopefully doesn't repeat the same mistakes.
> E4X (ECMAScript for XML) is a Javascript syntax extension and a runtime to manipulate XML. It was promoted by Mozilla but failed to become mainstream and is now deprecated. JSX was inspired by E4X. In this article, I'm going to go over all the features of E4X and explain the design decisions behind JSX.
>
> **Historical Context**
>
> E4X has been created in 2002 by John Schneider. This was the golden age of XML where it was being used for everything: data, configuration files, code, interfaces (DOM) ... E4X was first implemented inside of Rhino, a Javascript implementation from Mozilla written in Java.
>
> [Continue reading ...](http://blog.vjeux.com/2013/javascript/jsx-e4x-the-good-parts.html)
## React + Socket.io
[Geert Pasteels](http://enome.be/nl) made a small experiment with Socket.io. He wrote a very small mixin that synchronizes React state with the server. Just include this mixin to your React component and it is now live!
```javascript
changeHandler: function (data) {
if (!_.isEqual(data.state, this.state) && this.path === data.path) {
this.setState(data.state);
}
},
componentDidMount: function (root) {
this.path = utils.nodePath(root);
socket.on('component-change', this.changeHandler);
},
componentWillUpdate: function (props, state) {
socket.emit('component-change', { path: this.path, state: state });
},
componentWillUnmount: function () {
socket.removeListener('component-change', this.change);
}
```
[Check it out on GitHub...](https://github.com/Enome/react.io)
## cssobjectify
[Andrey Popp](http://andreypopp.com/) implemented a source transform that takes a CSS file and converts it to JSON. This integrates pretty nicely with React.
```javascript
/* style.css */
MyComponent {
font-size: 12px;
background-color: red;
}
/* myapp.js */
var React = require('react-tools/build/modules/React');
var Styles = require('./styles.css');
var MyComponent = React.createClass({
render: function() {
return (
<div style={Styles.MyComponent}>
Hello, world!
</div>
)
}
});
```
[Check it out on GitHub...](https://github.com/andreypopp/cssobjectify)
## ngReact
[David Chang](http://davidandsuzi.com/) working at [HasOffer](http://www.hasoffers.com/) wanted to speed up his Angular app and replaced Angular primitives by React at different layers. When using React naively it is 67% faster, but when combining it with angular's transclusion it is 450% slower.
> Rendering this takes 803ms for 10 iterations, hovering around 35 and 55ms for each data reload (that's 67% faster). You'll notice that the first load takes a little longer than successive loads, and the second load REALLY struggles - here, it's 433ms, which is more than half of the total time!
> <figure>[![](/react/img/blog/ngreact.png)](http://davidandsuzi.com/ngreact-react-components-in-angular/)</figure>
>
> [Read the full article...](http://davidandsuzi.com/ngreact-react-components-in-angular/)
## vim-jsx
[Max Wang](https://github.com/mxw) made a vim syntax highlighting and indentation plugin for vim.
> Syntax highlighting and indenting for JSX. JSX is a JavaScript syntax transformer which translates inline XML document fragments into JavaScript objects. It was developed by Facebook alongside React.
>
> This bundle requires pangloss's [vim-javascript](https://github.com/pangloss/vim-javascript) syntax highlighting.
>
> Vim support for inline XML in JS is remarkably similar to the same for PHP.
>
> [View on GitHub...](https://github.com/mxw/vim-jsx)
## Random Tweet
<center><blockquote class="twitter-tweet" lang="en"><p>I may be starting to get annoying with this, but ReactJS is really exciting. I truly feel the virtual DOM is a game changer.</p>&mdash; Eric Florenzano (@ericflo) <a href="https://twitter.com/ericflo/statuses/413842834974732288">December 20, 2013</a></blockquote></center>

View File

@@ -0,0 +1,19 @@
---
title: "React Chrome Developer Tools"
layout: post
author: Sebastian Markbåge
---
With the new year, we thought you'd enjoy some new tools for debugging React code. Today we're releasing the [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi), an extension to the Chrome Developer Tools. [Download them from the Chrome Web Store](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi).
<figure><iframe width="560" height="315" src="//www.youtube.com/embed/Cey7BS6dE0M" frameborder="0" allowfullscreen></iframe></figure>
You will get a new tab titled "React" in your Chrome DevTools. This tab shows you a list of the root React Components that are rendered on the page as well as the subcomponents that each root renders.
Selecting a Component in this tab allows you to view and edit its props and state in the panel on the right. In the breadcrumbs at the bottom, you can inspect the selected Component, the Component that created it, the Component that created that one, and so on.
When you inspect a DOM element using the regular Elements tab, you can switch over to the React tab and the corresponding Component will be automatically selected. The Component will also be automatically selected if you have a breakpoint within its render phase. This allows you to step through the render tree and see how one Component affects another one.
<figure>[![](/react/img/blog/react-dev-tools.jpg)](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi)</figure>
We hope these tools will help your team better understand your component hierarchy and track down bugs. We're very excited about this initial launch and appreciate any feedback you may have. As always, we also accept [pull requests on GitHub](https://github.com/facebook/react-devtools).

View File

@@ -0,0 +1,92 @@
---
title: "Community Round-up #14"
layout: post
author: Vjeux
---
The theme of this first round-up of 2014 is integration. I've tried to assemble a list of articles and projects that use React in various environments.
## React Baseline
React is only one-piece of your web application stack. [Mark Lussier](https://github.com/intabulas) shared his baseline stack that uses React along with Grunt, Browserify, Bower, Zepto, Director and Sass. This should help you get started using React for a new project.
> As I do more projects with ReactJS I started to extract a baseline to use when starting new projects. This is very opinionated and I change my opinion from time to time. This is by no ways perfect and in your opinion most likely wrong :).. which is why I love github
>
> I encourage you to fork, and make it right and submit a pull request!
>
> My current opinion is using tools like Grunt, Browserify, Bower and mutiple grunt plugins to get the job done. I also opted for Zepto over jQuery and the Flatiron Project's Director when I need a router. Oh and for the last little bit of tech that makes you mad, I am in the SASS camp when it comes to stylesheets
>
> [Check it out on GitHub...](https://github.com/intabulas/reactjs-baseline)
## Animal Sounds
[Josh Duck](http://joshduck.com/) used React in order to build a Windows 8 tablet app. This is a good example of a touch app written in React.
<figure>[![](/react/img/blog/animal-sounds.jpg)](http://apps.microsoft.com/windows/en-us/app/baby-play-animal-sounds/9280825c-2ed9-41c0-ba38-aa9a5b890bb9)</figure>
[Download the app...](http://apps.microsoft.com/windows/en-us/app/baby-play-animal-sounds/9280825c-2ed9-41c0-ba38-aa9a5b890bb9)
## React Rails Tutorial
[Selem Delul](http://selem.im) bundled the [React Tutorial](http://facebook.github.io/react/docs/tutorial.html) into a rails app. This is a good example on how to get started with a rails project.
> ```
git clone https://github.com/necrodome/react-rails-tutorial
cd react-rails-tutorial
bundle install
rake db:migrate
rails s
```
> Then visit http://localhost:3000/app to see the React application that is explained in the React Tutorial. Try opening multiple tabs!
>
> [View on GitHub...](https://github.com/necrodome/react-rails-tutorial)
## Mixing with Backbone
[Eldar Djafarov](http://eldar.djafarov.com/) implemented a mixin to link Backbone models to React state and a small abstraction to write two-way binding on-top.
<iframe width="100%" height="300" src="http://jsfiddle.net/djkojb/qZf48/13/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
[Check out the blog post...](http://eldar.djafarov.com/2013/11/reactjs-mixing-with-backbone/)
## React Infinite Scroll
[Guillaume Rivals](https://twitter.com/guillaumervls) implemented an InfiniteScroll component. This is a good example of a React component that has a simple yet powerful API.
```javascript
<InfiniteScroll
pageStart={0}
loadMore={loadFunc}
hasMore={true || false}
loader={<div className="loader">Loading ...</div>}>
{items} // <-- This is the "stuff" you want to load
</InfiniteScroll>
```
[Try it out on GitHub!](https://github.com/guillaumervls/react-infinite-scroll)
## Web Components Style
[Thomas Aylott](http://subtlegradient.com/) implemented an API that looks like Web Components but using React underneath.
<iframe width="100%" height="300" src="http://jsfiddle.net/SubtleGradient/ue2Aa/embedded/html,js,result" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
## React vs Angular
React is often compared with Angular. [Pete Hunt](http://skulbuny.com/2013/10/31/react-vs-angular/) wrote an opinionated post on the subject.
> First of all I think its important to evaluate technologies on objective rather than subjective features. “It feels nicer” or “its cleaner” arent valid reasons: performance, modularity, community size and ease of testing / integration with other tools are.
>
> Ive done a lot of work benchmarking, building apps, and reading the code of Angular to try to come up with a reasonable comparison between their ways of doing things.
>
> [Read the full post...](http://skulbuny.com/2013/10/31/react-vs-angular/)
## Random Tweet
<div><blockquote class="twitter-tweet" lang="en"><p>Really intrigued by React.js. I&#39;ve looked at all JS frameworks, and excepting <a href="https://twitter.com/serenadejs">@serenadejs</a> this is the first one which makes sense to me.</p>&mdash; Jonas Nicklas (@jonicklas) <a href="https://twitter.com/jonicklas/statuses/412640708755869696">December 16, 2013</a></blockquote></div>

View File

@@ -0,0 +1,126 @@
---
title: "Community Round-up #15"
layout: post
author: Jonas Gebhardt
---
Interest in React seems to have surged ever since David Nolen ([@swannodette](https://twitter.com/swannodette))'s introduction of [Om](https://github.com/swannodette/om) in his post ["The Future of Javascript MVC Frameworks"](http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/).
In this React Community Round-up, we are taking a closer look at React from a functional programming perspective.
## "React: Another Level of Indirection"
To start things off, Eric Normand ([@ericnormand](https://twitter.com/ericnormand)) of [LispCast](http://lispcast.com) makes the case for [React from a general functional programming standpoint](http://www.lispcast.com/react-another-level-of-indirection) and explains how React's "Virtual DOM provides the last piece of the Web Frontend Puzzle for ClojureScript".
> The Virtual DOM is an indirection mechanism that solves the difficult problem of DOM programming: how to deal with incremental changes to a stateful tree structure. By abstracting away the statefulness, the Virtual DOM turns the real DOM into an immediate mode GUI, which is perfect for functional programming.
>
> [Read the full post...](http://www.lispcast.com/react-another-level-of-indirection)
## Reagent: Minimalistic React for ClojureScript
Dan Holmsand ([@holmsand](https://twitter.com/holmsand)) created [Reagent](http://holmsand.github.io/reagent/), a simplistic ClojureScript API to React.
> It allows you to define efficient React components using nothing but plain ClojureScript functions and data, that describe your UI using a Hiccup-like syntax.
>
> The goal of Reagent is to make it possible to define arbitrarily complex UIs using just a couple of basic concepts, and to be fast enough by default that you rarely have to care about performance.
>
> [Check it out on Github...](http://holmsand.github.io/reagent/)
## Functional DOM programming
React's one-way data-binding naturally lends itself to a functional programming approach. Facebook's Pete Hunt ([@floydophone](https://twitter.com/floydophone)) explores how one would go about [writing web apps in a functional manner](https://medium.com/p/67d81637d43). Spoiler alert:
> This is React. Its not about templates, or data binding, or DOM manipulation. Its about using functional programming with a virtual DOM representation to build ambitious, high-performance apps with JavaScript.
>
> [Read the full post...](https://medium.com/p/67d81637d43)
Pete also explains this in detail at his #MeteorDevShop talk (about 30 Minutes):
<iframe width="560" height="315" src="//www.youtube.com/embed/Lqcs6hPOcFw?start=2963" frameborder="0" allowfullscreen></iframe>
## Kioo: Separating markup and logic
[Creighton Kirkendall](https://github.com/ckirkendall) created [Kioo](https://github.com/ckirkendall/kioo), which adds Enlive-style templating to React. HTML templates are separated from the application logic. Kioo comes with separate examples for both Om and Reagent.
A basic example from github:
```html
<!DOCTYPE html>
<html lang="en">
<body>
<header>
<h1>Header placeholder</h1>
<ul id="navigation">
<li class="nav-item"><a href="#">Placeholder</a></li>
</ul>
</header>
<div class="content">place holder</div>
</body>
</html>
```
```clojure
...
(defn my-nav-item [[caption func]]
(kioo/component "main.html" [:.nav-item]
{[:a] (do-> (content caption)
(set-attr :onClick func))}))
(defn my-header [heading nav-elms]
(kioo/component "main.html" [:header]
{[:h1] (content heading)
[:ul] (content (map my-nav-item nav-elms))}))
(defn my-page [data]
(kioo/component "main.html"
{[:header] (substitute (my-header (:heading data)
(:navigation data)))
[:.content] (content (:content data))}))
(def app-state (atom {:heading "main"
:content "Hello World"
:navigation [["home" #(js/alert %)]
["next" #(js/alert %)]]}))
(om/root app-state my-page (.-body js/document))
```
## Om
In an interview with David Nolen, Tom Coupland ([@tcoupland](https://twitter.com/tcoupland)) of InfoQ provides a nice summary of recent developments around Om ("[Om: Enhancing Facebook's React with Immutability](http://www.infoq.com/news/2014/01/om-react)").
> David [Nolen]: I think people are starting to see the limitations of just JavaScript and jQuery and even more structured solutions like Backbone, Angular, Ember, etc. React is a fresh approach to the DOM problem that seems obvious in hindsight.
>
> [Read the full interview...](http://www.infoq.com/news/2014/01/om-react)
### A slice of React, ClojureScript and Om
Fredrik Dyrkell ([@lexicallyscoped](https://twitter.com/lexicallyscoped)) rewrote part of the [React tutorial in both ClojureScript and Om](http://www.lexicallyscoped.com/2013/12/25/slice-of-reactjs-and-cljs.html), along with short, helpful explanations.
> React has sparked a lot of interest in the Clojure community lately [...]. At the very core, React lets you build up your DOM representation in a functional fashion by composing pure functions and you have a simple building block for everything: React components.
>
> [Read the full post...](http://www.lexicallyscoped.com/2013/12/25/slice-of-reactjs-and-cljs.html)
In a separate post, Dyrkell breaks down [how to build a binary clock component](http://www.lexicallyscoped.com/2014/01/23/ClojureScript-react-om-binary-clock.html) in Om.
[[Demo](http://www.lexicallyscoped.com/demo/binclock/)] [[Code](https://github.com/fredyr/binclock/blob/master/src/binclock/core.cljs)]
### Time Travel: Implementing undo in Om
David Nolen shows how to leverage immutable data structures to [add global undo](http://swannodette.github.io/2013/12/31/time-travel/) functionality to an app using just 13 lines of ClojureScript.
### A Step-by-Step Om Walkthrough
[Josh Lehman](http://www.joshlehman.me) took the time to create an extensive [step-by-step walkthrough](http://www.joshlehman.me/rewriting-the-react-tutorial-in-om/) of the React tutorial in Om. The well-documented source is on [github](https://github.com/jalehman/omtut-starter).
### Omkara
[brendanyounger](https://github.com/brendanyounger) created [omkara](https://github.com/brendanyounger/omkara), a starting point for ClojureScript web apps based on Om/React. It aims to take advantage of server-side rendering and comes with a few tips on getting started with Om/React projects.
### Om Experience Report
Adam Solove ([@asolove](https://twitter.com/asolove/)) [dives a little deeper into Om, React and ClojureScript](http://adamsolove.com/js/clojure/2014/01/06/om-experience-report.html). He shares some helpful tips he gathered while building his [CartoCrayon](https://github.com/asolove/carto-crayon) prototype.
## Not-so-random Tweet
<div><blockquote class="twitter-tweet" lang="en"><p>[@swannodette](https://twitter.com/swannodette) No thank you! It's honestly a bit weird because Om is exactly what I didn't know I wanted for doing functional UI work.</p>&mdash; Adam Solove (@asolove) <a href="https://twitter.com/asolove/status/420294067637858304">January 6, 2014</a></blockquote></div>

View File

@@ -0,0 +1,86 @@
---
title: "Community Round-up #16"
layout: post
author: Jonas Gebhardt
---
There have been many posts recently covering the <i>why</i> and <i>how</i> of React. This week's community round-up includes a collection of recent articles to help you get started with React, along with a few posts that explain some of the inner workings.
## React in a nutshell
Got five minutes to pitch React to your coworkers? John Lynch ([@johnrlynch](https://twitter.com/johnrlynch)) put together [this excellent and refreshing slideshow](http://slid.es/johnlynch/reactjs):
<iframe src="//slid.es/johnlynch/reactjs/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
## React's diff algorithm
React core team member Christopher Chedeau ([@vjeux](https://twitter.com/vjeux)) explores the innards of React's tree diffing algorithm in this [extensive and well-illustrated post](http://calendar.perfplanet.com/2013/diff/). <figure>[![](/react/img/blog/react-diff-tree.png)](http://calendar.perfplanet.com/2013/diff/)</figure>
While we're talking about tree diffing: Matt Esch ([@MatthewEsch](https://twitter.com/MatthewEsch)) created [this project](https://github.com/Matt-Esch/virtual-dom), which aims to implement the virtual DOM and a corresponding diff algorithm as separate modules.
## Many, many new introductions to React!
James Padosley wrote a short post on the basics (and merits) of React: [What is React?](http://james.padolsey.com/javascript/what-is-react/)
> What I like most about React is that it doesn't impose heady design patterns and data-modelling abstractions on me. [...] Its opinions are so minimal and its abstractions so focused on the problem of the DOM, that you can merrily slap your design choices atop.
> [Read the full post...](http://james.padolsey.com/javascript/what-is-react/)
Taylor Lapeyre ([@taylorlapeyre](https://twitter.com/taylorlapeyre)) wrote another nice [introduction to React](http://words.taylorlapeyre.me/an-introduction-to-react).
> React expects you to do the work of getting and pushing data from the server. This makes it very easy to implement React as a front end solution, since it simply expects you to hand it data. React does all the other work.
> [Read the full post...](http://words.taylorlapeyre.me/an-introduction-to-react)
[This "Deep explanation for newbies"](http://www.webdesignporto.com/react-js-in-pure-javascript-facebook-library/?utm_source=echojs&utm_medium=post&utm_campaign=echojs) by [@ProJavaScript](https://twitter.com/ProJavaScript) explains how to get started building a React game without using the optional JSX syntax.
### React around the world
It's great to see the React community expand internationally. [This site](http://habrahabr.ru/post/189230/) features a React introduction in Russian.
### React tutorial series
[Christopher Pitt](https://medium.com/@followchrisp) explains [React Components](https://medium.com/react-tutorials/828c397e3dc8) and [React Properties](https://medium.com/react-tutorials/ef11cd55caa0). The former includes a nice introduction to using JSX, while the latter focuses on adding interactivity and linking multiple components together. Also check out the [other posts in his React Tutorial series](https://medium.com/react-tutorials), e.g. on using [React + Backbone Model](https://medium.com/react-tutorials/8aaec65a546c) and [React + Backbone Router](https://medium.com/react-tutorials/c00be0cf1592).
### Beginner tutorial: Implementing the board game Go
[Chris LaRose](http://cjlarose.com/) walks through the steps of creating a Go app in React, showing how to separate application logic from the rendered components. Check out his [tutorial](http://cjlarose.com/2014/01/09/react-board-game-tutorial.html) or go straight to the [code](https://github.com/cjlarose/react-go).
### Egghead.io video tutorials
Joe Maddalone ([@joemaddalone](https://twitter.com/joemaddalone)) of [egghead.io](https://egghead.io/) created a series of React video tutorials, such as [this](http://www.youtube.com/watch?v=rFvZydtmsxM&feature=youtu.be&a) introduction to React Components. [[part 1](http://www.youtube.com/watch?v=rFvZydtmsxM&feature=youtu.be&a)], [[part 2](http://www.youtube.com/watch?v=5yvFLrt7N8M)]
### "React: Finally, a great server/client web stack"
Eric Florenzano ([@ericflo](https://twitter.com/ericflo)) sheds some light on what makes React perfect for server rendering:
> [...] the ideal solution would fully render the markup on the server, deliver it to the client so that it can be shown to the user instantly. Then it would asynchronously load some Javascript that would attach to the rendered markup, and invisibly promote the page into a full app that can render its own markup. [...]
> What I've discovered is that enough of the pieces have come together, that this futuristic-sounding web environment is actually surprisingly easy to do now with React.js.
> [Read the full post...](http://eflorenzano.com/blog/2014/01/23/react-finally-server-client/)
## Building a complex React component
[Matt Harrison](http://matt-harrison.com/) walks through the process of [creating an SVG-based Resistance Calculator](http://matt-harrison.com/building-a-complex-web-component-with-facebooks-react-library/) using React. <figure>[![](/react/img/blog/resistance-calculator.png)](http://matt-harrison.com/building-a-complex-web-component-with-facebooks-react-library/)</figure>
## Random Tweets
<div><blockquote class="twitter-tweet" lang="en"><p>[#reactjs](https://twitter.com/search?q=%23reactjs&src=hash) has very simple API, but it's amazing how much work has been done under the hood to make it blazing fast.</p>&mdash; Anton Astashov (@anton_astashov) <a href="https://twitter.com/anton_astashov/status/417556491646693378">December 30, 2013</a></blockquote></div>
<div><blockquote class="twitter-tweet" lang="en"><p>[#reactjs]((https://twitter.com/search?q=%23reactjs&src=hash) makes refactoring your HTML as easy & natural as refactoring your javascript [@react_js](https://twitter.com/react_js)</p>&mdash; Jared Forsyth (@jaredforsyth) <a href="https://twitter.com/jaredforsyth/status/420304083010854912">January 6, 2014</a></blockquote></div>
<div><blockquote class="twitter-tweet" lang="en"><p>Played with react.js for an hour, so many things suddenly became stupidly simple.</p>&mdash; andrewingram (@andrewingram) <a href="https://twitter.com/andrewingram/status/422810480701620225">January 13, 2014</a></blockquote></div>
<div><blockquote class="twitter-tweet" lang="en"><p>[@okonetchnikov](https://twitter.com/okonetchnikov) HOLY CRAP react is nice</p>&mdash; julik (@julikt) <a href="https://twitter.com/julikt/status/422843478792765440">January 13, 2014</a></blockquote></div>
<div><blockquote class="twitter-tweet" lang="en"><p>brb rewriting everything with react
</p>&mdash; Ben Smithett (@bensmithett) <a href="https://twitter.com/bensmithett/status/430671242186592256">February 4, 2014</a></blockquote></div>

View File

@@ -0,0 +1,133 @@
---
title: React v0.9 RC
layout: post
author: Ben Alpert
---
We're almost ready to release React v0.9! We're posting a release candidate so that you can test your apps on it; we'd much prefer to find show-stopping bugs now rather than after we release.
The release candidate is available for download from the CDN:
* **React**
Dev build with warnings: <http://fb.me/react-0.9.0-rc1.js>
Minified build for production: <http://fb.me/react-0.9.0-rc1.min.js>
* **React with Add-Ons**
Dev build with warnings: <http://fb.me/react-with-addons-0.9.0-rc1.js>
Minified build for production: <http://fb.me/react-with-addons-0.9.0-rc1.min.js>
* **In-Browser JSX transformer**
<http://fb.me/JSXTransformer-0.9.0-rc1.js>
We've also published version `0.9.0-rc1` of the `react` and `react-tools` packages on npm and the `react` package on bower.
Please try these builds out and [file an issue on GitHub](https://github.com/facebook/react/issues/new) if you see anything awry.
## Upgrade Notes
In addition to the changes to React core listed below, we've made a small change to the way JSX interprets whitespace to make things more consistent. With this release, space between two components on the same line will be preserved, while a newline separating a text node from a tag will be eliminated in the output. Consider the code:
```html
<div>
Monkeys:
{listOfMonkeys} {submitButton}
</div>
```
In v0.8 and below, it was transformed to the following:
```javascript
React.DOM.div(null,
" Monkeys: ",
listOfMonkeys, submitButton
)
```
In v0.9, it will be transformed to this JS instead:
```javascript{2,3}
React.DOM.div(null,
"Monkeys:",
listOfMonkeys, " ", submitButton
)
```
We believe this new behavior is more helpful and elimates cases where unwanted whitespace was previously added.
In cases where you want to preserve the space adjacent to a newline, you can write a JS string like `{"Monkeys: "}` in your JSX source. We've included a script to do an automated codemod of your JSX source tree that preserves the old whitespace behavior by adding and removing spaces appropriately. You can [install jsx\_whitespace\_transformer from npm](https://github.com/facebook/react/blob/master/npm-jsx_whitespace_transformer/README.md) and run it over your source tree to modify files in place. The transformed JSX files will preserve your code's existing whitespace behavior.
## Changelog
### React Core
#### Breaking Changes
- The lifecycle methods `componentDidMount` and `componentDidUpdate` no longer receive the root node as a parameter; use `this.getDOMNode()` instead
- Whenever a prop is equal to `undefined`, the default value returned by `getDefaultProps` will now be used instead
- `React.unmountAndReleaseReactRootNode` was previously deprecated and has now been removed
- `React.renderComponentToString` is now synchronous and returns the generated HTML string
- Full-page rendering (that is, rendering the `<html>` tag using React) is now supported only when starting with server-rendered markup
- On mouse wheel events, `deltaY` is no longer negated
- When prop types validation fails, a warning is logged instead of an error thrown (with the production build of React, the type checks are now skipped for performance)
- On `input`, `select`, and `textarea` elements, `.getValue()` is no longer supported; use `.getDOMNode().value` instead
- `this.context` on components is now reserved for internal use by React
#### New Features
- React now never rethrows errors, so stack traces are more accurate and Chrome's purple break-on-error stop sign now works properly
- Added a new tool for profiling React components and identifying places where defining `shouldComponentUpdate` can give performance improvements
- Added support for SVG tags `defs`, `linearGradient`, `polygon`, `radialGradient`, `stop`
- Added support for more attributes:
- `noValidate` and `formNoValidate` for forms
- `property` for Open Graph `<meta>` tags
- `sandbox`, `seamless`, and `srcDoc` for `<iframe>` tags
- `scope` for screen readers
- `span` for `<colgroup>` tags
- Added support for defining `propTypes` in mixins
- Added `any`, `arrayOf`, `component`, `oneOfType`, `renderable`, `shape` to `React.PropTypes`
- Added support for `statics` on component spec for static component methods
- On all events, `.currentTarget` is now properly set
- On keyboard events, `.key` is now polyfilled in all browsers for special (non-printable) keys
- On clipboard events, `.clipboardData` is now polyfilled in IE
- On drag events, `.dataTransfer` is now present
- Added support for `onMouseOver` and `onMouseOut` in addition to the existing `onMouseEnter` and `onMouseLeave` events
- Added support for `onLoad` and `onError` on `<img>` elements
- Added support for `onReset` on `<form>` elements
- The `autoFocus` attribute is now polyfilled consistently on `input`, `select`, and `textarea`
#### Bug Fixes
- React no longer adds an `__owner__` property to each component's `props` object; passed-in props are now never mutated
- When nesting top-level components (e.g., calling `React.renderComponent` within `componentDidMount`), events now properly bubble to the parent component
- Fixed a case where nesting top-level components would throw an error when updating
- Passing an invalid or misspelled propTypes type now throws an error
- On mouse enter/leave events, `.target`, `.relatedTarget`, and `.type` are now set properly
- On composition events, `.data` is now properly normalized in IE9 and IE10
- CSS property values no longer have `px` appended for the unitless properties `columnCount`, `flex`, `flexGrow`, `flexShrink`, `lineClamp`, `order`, `widows`
- Fixed a memory leak when unmounting children with a `componentWillUnmount` handler
- Fixed a memory leak when `renderComponentToString` would store event handlers
- Fixed an error that could be thrown when removing form elements during a click handler
- `key` values containing `.` are now supported
- Shortened `data-reactid` values for performance
- Components now always remount when the `key` property changes
- Event handlers are attached to `document` only when necessary, improving performance in some cases
- Events no longer use `.returnValue` in modern browsers, eliminating a warning in Chrome
- `scrollLeft` and `scrollTop` are no longer accessed on document.body, eliminating a warning in Chrome
- General performance fixes, memory optimizations, improvements to warnings and error messages
### React with Addons
- `React.addons.TransitionGroup` was renamed to `React.addons.CSSTransitionGroup`
- `React.addons.TransitionGroup` was added as a more general animation wrapper
- `React.addons.cloneWithProps` was added for cloning components and modifying their props
- Bug fix for adding back nodes during an exit transition for CSSTransitionGroup
- Bug fix for changing `transitionLeave` in CSSTransitionGroup
- Performance optimizations for CSSTransitionGroup
- On checkbox `<input>` elements, `checkedLink` is now supported for two-way binding
### JSX Compiler and react-tools Package
- Whitespace normalization has changed; now space between two tags on the same line will be preserved, while newlines between two tags will be removed
- The `react-tools` npm package no longer includes the React core libraries; use the `react` package instead.
- `displayName` is now added in more cases, improving error messages and names in the React Dev Tools
- Fixed an issue where an invalid token error was thrown after a JSX closing tag
- `JSXTransformer` now uses source maps automatically in modern browsers
- `JSXTransformer` error messages now include the filename and problematic line contents when a file fails to parse

View File

@@ -0,0 +1,145 @@
---
title: React v0.9
layout: post
author: Ben Alpert
---
I'm excited to announce that today we're releasing React v0.9, which incorporates many bug fixes and several new features since the last release. This release contains almost four months of work, including over 800 commits from over 70 committers!
Thanks to everyone who tested the release candidate; we were able to find and fix an error in the event handling code, we upgraded envify to make running browserify on React faster, and we added support for five new attributes.
As always, the release is available for download from the CDN:
* **React**
Dev build with warnings: <http://fb.me/react-0.9.0.js>
Minified build for production: <http://fb.me/react-0.9.0.min.js>
* **React with Add-Ons**
Dev build with warnings: <http://fb.me/react-with-addons-0.9.0.js>
Minified build for production: <http://fb.me/react-with-addons-0.9.0.min.js>
* **In-Browser JSX Transformer**
<http://fb.me/JSXTransformer-0.9.0.js>
We've also published version `0.9.0` of the `react` and `react-tools` packages on npm and the `react` package on bower.
## Whats New?
This version includes better support for normalizing event properties across all supported browsers so that you need to worry even less about cross-browser differences. We've also made many improvements to error messages and have refactored the core to never rethrow errors, so stack traces are more accurate and Chrome's purple break-on-error stop sign now works properly.
We've also added to the add-ons build [React.addons.TestUtils](/react/docs/test-utils.html), a set of new utilities to help you write unit tests for React components. You can now simulate events on your components, and several helpers are provided to help make assertions about the rendered DOM tree.
We've also made several other improvements and a few breaking changes; the full changelog is provided below.
## JSX Whitespace
In addition to the changes to React core listed below, we've made a small change to the way JSX interprets whitespace to make things more consistent. With this release, space between two components on the same line will be preserved, while a newline separating a text node from a tag will be eliminated in the output. Consider the code:
```html
<div>
Monkeys:
{listOfMonkeys} {submitButton}
</div>
```
In v0.8 and below, it was transformed to the following:
```javascript
React.DOM.div(null,
" Monkeys: ",
listOfMonkeys, submitButton
)
```
In v0.9, it will be transformed to this JS instead:
```javascript{2,3}
React.DOM.div(null,
"Monkeys:",
listOfMonkeys, " ", submitButton
)
```
We believe this new behavior is more helpful and elimates cases where unwanted whitespace was previously added.
In cases where you want to preserve the space adjacent to a newline, you can write `{'Monkeys: '}` or `Monkeys:{' '}` in your JSX source. We've included a script to do an automated codemod of your JSX source tree that preserves the old whitespace behavior by adding and removing spaces appropriately. You can [install jsx\_whitespace\_transformer from npm](https://github.com/facebook/react/blob/master/npm-jsx_whitespace_transformer/README.md) and run it over your source tree to modify files in place. The transformed JSX files will preserve your code's existing whitespace behavior.
## Changelog
### React Core
#### Breaking Changes
- The lifecycle methods `componentDidMount` and `componentDidUpdate` no longer receive the root node as a parameter; use `this.getDOMNode()` instead
- Whenever a prop is equal to `undefined`, the default value returned by `getDefaultProps` will now be used instead
- `React.unmountAndReleaseReactRootNode` was previously deprecated and has now been removed
- `React.renderComponentToString` is now synchronous and returns the generated HTML string
- Full-page rendering (that is, rendering the `<html>` tag using React) is now supported only when starting with server-rendered markup
- On mouse wheel events, `deltaY` is no longer negated
- When prop types validation fails, a warning is logged instead of an error thrown (with the production build of React, type checks are now skipped for performance)
- On `input`, `select`, and `textarea` elements, `.getValue()` is no longer supported; use `.getDOMNode().value` instead
- `this.context` on components is now reserved for internal use by React
#### New Features
- React now never rethrows errors, so stack traces are more accurate and Chrome's purple break-on-error stop sign now works properly
- Added support for SVG tags `defs`, `linearGradient`, `polygon`, `radialGradient`, `stop`
- Added support for more attributes:
- `crossOrigin` for CORS requests
- `download` and `hrefLang` for `<a>` tags
- `mediaGroup` and `muted` for `<audio>` and `<video>` tags
- `noValidate` and `formNoValidate` for forms
- `property` for Open Graph `<meta>` tags
- `sandbox`, `seamless`, and `srcDoc` for `<iframe>` tags
- `scope` for screen readers
- `span` for `<colgroup>` tags
- Added support for defining `propTypes` in mixins
- Added `any`, `arrayOf`, `component`, `oneOfType`, `renderable`, `shape` to `React.PropTypes`
- Added support for `statics` on component spec for static component methods
- On all events, `.currentTarget` is now properly set
- On keyboard events, `.key` is now polyfilled in all browsers for special (non-printable) keys
- On clipboard events, `.clipboardData` is now polyfilled in IE
- On drag events, `.dataTransfer` is now present
- Added support for `onMouseOver` and `onMouseOut` in addition to the existing `onMouseEnter` and `onMouseLeave` events
- Added support for `onLoad` and `onError` on `<img>` elements
- Added support for `onReset` on `<form>` elements
- The `autoFocus` attribute is now polyfilled consistently on `input`, `select`, and `textarea`
#### Bug Fixes
- React no longer adds an `__owner__` property to each component's `props` object; passed-in props are now never mutated
- When nesting top-level components (e.g., calling `React.renderComponent` within `componentDidMount`), events now properly bubble to the parent component
- Fixed a case where nesting top-level components would throw an error when updating
- Passing an invalid or misspelled propTypes type now throws an error
- On mouse enter/leave events, `.target`, `.relatedTarget`, and `.type` are now set properly
- On composition events, `.data` is now properly normalized in IE9 and IE10
- CSS property values no longer have `px` appended for the unitless properties `columnCount`, `flex`, `flexGrow`, `flexShrink`, `lineClamp`, `order`, `widows`
- Fixed a memory leak when unmounting children with a `componentWillUnmount` handler
- Fixed a memory leak when `renderComponentToString` would store event handlers
- Fixed an error that could be thrown when removing form elements during a click handler
- Boolean attributes such as `disabled` are rendered without a value (previously `disabled="true"`, now simply `disabled`)
- `key` values containing `.` are now supported
- Shortened `data-reactid` values for performance
- Components now always remount when the `key` property changes
- Event handlers are attached to `document` only when necessary, improving performance in some cases
- Events no longer use `.returnValue` in modern browsers, eliminating a warning in Chrome
- `scrollLeft` and `scrollTop` are no longer accessed on document.body, eliminating a warning in Chrome
- General performance fixes, memory optimizations, improvements to warnings and error messages
### React with Addons
- `React.addons.TestUtils` was added to help write unit tests
- `React.addons.TransitionGroup` was renamed to `React.addons.CSSTransitionGroup`
- `React.addons.TransitionGroup` was added as a more general animation wrapper
- `React.addons.cloneWithProps` was added for cloning components and modifying their props
- Bug fix for adding back nodes during an exit transition for CSSTransitionGroup
- Bug fix for changing `transitionLeave` in CSSTransitionGroup
- Performance optimizations for CSSTransitionGroup
- On checkbox `<input>` elements, `checkedLink` is now supported for two-way binding
### JSX Compiler and react-tools Package
- Whitespace normalization has changed; now space between two tags on the same line will be preserved, while newlines between two tags will be removed
- The `react-tools` npm package no longer includes the React core libraries; use the `react` package instead.
- `displayName` is now added in more cases, improving error messages and names in the React Dev Tools
- Fixed an issue where an invalid token error was thrown after a JSX closing tag
- `JSXTransformer` now uses source maps automatically in modern browsers
- `JSXTransformer` error messages now include the filename and problematic line contents when a file fails to parse

View File

@@ -0,0 +1,95 @@
---
title: "Community Round-up #17"
layout: post
author: Jonas Gebhardt
---
It's exciting to see the number of real-world React applications and components skyrocket over the past months! This community round-up features a few examples of inspiring React applications and components.
## React in the Real World
### Facebook Lookback video editor
Large parts of Facebook's web frontend are already powered by React. The recently released Facebook [Lookback video and its corresponding editor](https://www.facebook.com/lookback/edit/) are great examples of a complex, real-world React app.
### Russia's largest bank is now powered by React
Sberbank, Russia's largest bank, recently switched large parts of their site to use React, as detailed in [this post by Vyacheslav Slinko](https://groups.google.com/forum/#!topic/reactjs/Kj6WATX0atg).
### Relato
[Relato](http://bripkens.github.io/relato/) by [Ben Ripkens](https://github.com/bripkens) shows Open Source Statistics based on npm data. It features a filterable and sortable table built in React. Check it out &ndash; it's super fast!
### Makona Editor
John Lynch ([@johnrlynch](https://twitter.com/johnrlynch)) created Makona, a block-style document editor for the web. Blocks of different content types comprise documents, authored using plain markup. At the switch of a toggle, block contents are then rendered on the page. While not quite a WYSIWYG editor, Makona uses plain textareas for input. This makes it compatible with a wider range of platforms than traditional rich text editors.
<figure>[![](/react/img/blog/makona-editor.png)](http://johnthethird.github.io/makona-editor/)</figure>
### Create Chrome extensions using React
React is in no way limited to just web pages. Brandon Tilley ([@BinaryMuse](https://twitter.com/BinaryMuse)) just released a detailed walk-through of [how he built his Chrome extension "Fast Tab Switcher" using React](http://brandontilley.com/2014/02/24/creating-chrome-extensions-with-react.html).
### Twitter Streaming Client
Javier Aguirre ([@javaguirre](https://twitter.com/javaguirre)) put together a simple [twitter streaming client using node, socket.io and React](http://javaguirre.net/2014/02/11/twitter-streaming-api-with-node-socket-io-and-reactjs/).
### Sproutsheet
[Sproutsheet](http://sproutsheet.com/) is a gardening calendar. You can use it to track certain events that happen in the life of your plants. It's currently in beta and supports localStorage, and data/image import and export.
### Instant Domain Search
[Instant Domain Search](https://instantdomainsearch.com/) also uses React. It sure is instant!
### SVG-based graphical node editor
[NoFlo](http://noflojs.org/) and [Meemoo](http://meemoo.org/) developer [Forresto Oliphant](http://www.forresto.com/) built an awesome SVG-based [node editor](http://forresto.github.io/prototyping/react/) in React.
<figure>[![](/react/img/blog/react-svg-fbp.png)](http://forresto.github.io/prototyping/react/)</figure>
### Ultimate Tic-Tac-Toe Game in React
Rafał Cieślak ([@Ravicious](https://twitter.com/Ravicious)) wrote a [React version](http://ravicious.github.io/ultimate-ttt/) of [Ultimate Tic Tac Toe](http://mathwithbaddrawings.com/2013/06/16/ultimate-tic-tac-toe/). Find the source [here](https://github.com/ravicious/ultimate-ttt).
### ReactJS Gallery
[Emanuele Rampichini](https://github.com/lele85)'s [ReactJS Gallery](https://github.com/lele85/ReactGallery) is a cool demo app that shows fullscreen images from a folder on the server. If the folder content changes, the gallery app updates via websockets.
Emanuele shared this awesome demo video with us:
<iframe width="560" height="315" src="//www.youtube.com/embed/jYcpaemt90M" frameborder="0" allowfullscreen></iframe>
## React Components
### Table Sorter
[Table Sorter](http://bgerm.github.io/react-table-sorter-demo/) by [bgerm](https://github.com/bgerm) [[source](https://github.com/bgerm/react-table-sorter-demo)] is another helpful React component.
### Static-search
Dmitry Chestnykh [@dchest](https://twitter.com/dchest) wrote a [static search indexer](https://github.com/dchest/static-search) in Go, along with a [React-based web front-end](http://www.codingrobots.com/search/) that consumes search result via JSON.
### Lorem Ipsum component
[Martin Andert](https://github.com/martinandert) created [react-lorem-component](https://github.com/martinandert/react-lorem-component), a simple component for all your placeholding needs.
### Input with placeholder shim
[react-input=placeholder](https://github.com/enigma-io/react-input-placeholder) by [enigma-io](https://github.com/enigma-io) is a small wrapper around React.DOM.input that shims in placeholder functionality for browsers that don't natively support it.
### diContainer
[dicontainer](https://github.com/SpektrumFM/dicontainer) provides a dependency container that lets you inject Angular-style providers and services as simple React.js Mixins.
## React server rendering
Ever wonder how to pre-render React components on the server? [react-server-example](https://github.com/mhart/react-server-example) by Michael Hart ([@hichaelmart](http://twitter.com/hichaelmart)) walks through the necessary steps.
Similarly, Alan deLevie ([@adelevie](https://twitter.com/adelevie)) created [react-client-server-starter](https://github.com/adelevie/react-client-server-starter), another detailed walk-through of how to server-render your app.
## Random Tweet
<div><blockquote class="twitter-tweet" lang="en"><p>Recent changes: web ui is being upgraded to [#reactjs](https://twitter.com/search?q=%23reactjs&src=hash), HEAD~4 at [https://camlistore.googlesource.com/camlistore/](https://camlistore.googlesource.com/camlistore/)</p>&mdash; Camlistore (@Camlistore) <a href="https://twitter.com/Camlistore/status/423925795820539904">January 16, 2014</a></blockquote></div>

View File

@@ -0,0 +1,106 @@
---
title: "Community Round-up #18"
layout: post
author: Jonas Gebhardt
---
In this Round-up, we are taking a few closer looks at React's interplay with different frameworks and architectures.
## "Little framework BIG splash"
Let's start with yet another refreshing introduction to React: Craig Savolainen ([@maedhr](https://twitter.com/maedhr)) walks through some first steps, demonstrating [how to build a Google Maps component](http://infinitemonkeys.influitive.com/little-framework-big-splash) using React.
## Architecting your app with react
Brandon Konkle ([@bkonkle](https://twitter.com/bkonkle))
[Architecting your app with react](http://lincolnloop.com/blog/architecting-your-app-react-part-1/)
We're looking forward to part 2!
> React is not a full MVC framework, and this is actually one of its strengths. Many who adopt React choose to do so alongside their favorite MVC framework, like Backbone. React has no opinions about routing or syncing data, so you can easily use your favorite tools to handle those aspects of your frontend application. You'll often see React used to manage specific parts of an application's UI and not others. React really shines, however, when you fully embrace its strategies and make it the core of your application's interface.
>
> [Read the full article...](http://lincolnloop.com/blog/architecting-your-app-react-part-1/)
## React vs. async DOM manipulation
Eliseu Monar ([@eliseumds](https://twitter.com/eliseumds))'s post "[ReactJS vs async concurrent rendering](http://eliseu.tk/post/77843550010/vitalbox-pchr-reactjs-vs-async-concurrent-rendering)" is a great example of how React quite literally renders a whole array of common web development work(arounds) obsolete.
## React, Scala and the Play Framework
[Matthias Nehlsen](http://matthiasnehlsen.com/) wrote a detailed introductory piece on [React and the Play Framework](http://matthiasnehlsen.com/blog/2014/01/05/play-framework-and-facebooks-react-library/), including a helpful architectural diagram of a typical React app.
Nehlsen's React frontend is the second implementation of his chat application's frontend, following an AngularJS version. Both implementations are functionally equivalent and offer some perspective on differences between the two frameworks.
In [another article](http://matthiasnehlsen.com/blog/2014/01/24/scala-dot-js-and-reactjs/), he walks us through the process of using React with scala.js to implement app-wide undo functionality.
Also check out his [talk](http://m.ustream.tv/recorded/42780242) at Ping Conference 2014, in which he walks through a lot of the previously content in great detail.
## React and Backbone
The folks over at [Venmo](https://venmo.com/) are using React in conjunction with Backbone.
Thomas Boyt ([@thomasaboyt](https://twitter.com/thomasaboyt)) wrote [this detailed piece](http://www.thomasboyt.com/2013/12/17/using-reactjs-as-a-backbone-view.html) about why React and Backbone are "a fantastic pairing".
## React vs. Ember
Eric Berry ([@coderberry](https://twitter.com/coderberry)) developed Ember equivalents for some of the official React examples. Read his post for a side-by-side comparison of the respective implementations: ["Facebook React vs. Ember"](http://instructure.github.io/blog/2013/12/17/facebook-react-vs-ember/).
## React and plain old HTML
Daniel Lo Nigro ([@Daniel15](https://twitter.com/Daniel15)) created [React-Magic](https://github.com/reactjs/react-magic), which leverages React to ajaxify plain old html pages and even [allows CSS transitions between pageloads](http://stuff.dan.cx/facebook/react-hacks/magic/red.php).
> React-Magic intercepts all navigation (link clicks and form posts) and loads the requested page via an AJAX request. React is then used to "diff" the old HTML with the new HTML, and only update the parts of the DOM that have been changed.
>
> [Check out the project on GitHub...](https://github.com/reactjs/react-magic)
On a related note, [Reactize](https://turbo-react.herokuapp.com/) by Ross Allen ([@ssorallen](https://twitter.com/ssorallen)) is a similarly awesome project: A wrapper for Rails' [Turbolinks](https://github.com/rails/turbolinks/), which seems to have inspired John Lynch ([@johnrlynch](https://twitter.com/johnrlynch)) to then create [a server-rendered version using the JSX transformer in Rails middleware](http://www.rigelgroupllc.com/blog/2014/01/12/react-jsx-transformer-in-rails-middleware/).
## React and Object.observe
Check out [François de Campredon](https://github.com/fdecampredon)'s implementation of [TodoMVC based on React and ES6's Object.observe](https://github.com/fdecampredon/react-observe-todomvc/).
## React and Angular
Ian Bicking ([@ianbicking](https://twitter.com/ianbicking)) of Mozilla Labs [explains why he "decided to go with React instead of Angular.js"](https://plus.google.com/+IanBicking/posts/Qj8R5SWAsfE).
### ng-React Update
[David Chang](https://github.com/davidchang) works through some performance improvements of his [ngReact](https://github.com/davidchang/ngReact) project. His post ["ng-React Update - React 0.9 and Angular Track By"](http://davidandsuzi.com/ngreact-update/) includes some helpful advice on boosting render performance for Angular components.
> Angular gives you a ton of functionality out of the box - a full MV* framework - and I am a big fan, but I'll admit that you need to know how to twist the right knobs to get performance.
>
> That said, React gives you a very strong view component out of the box with the performance baked right in. Try as I did, I couldn't actually get it any faster. So pretty impressive stuff.
>
>[Read the full post...](http://davidandsuzi.com/ngreact-update/)
React was also recently mentioned at ng-conf, where the Angular team commented on React's concept of the virtual DOM:
<iframe width="560" height="315" src="//www.youtube.com/embed/srt3OBP2kGc?start=113" frameborder="0" allowfullscreen></iframe>
## React and Web Components
Jonathan Krause ([@jonykrause](https://twitter.com/jonykrause)) offers his thoughts regarding [parallels between React and Web Components](http://jonykrau.se/posts/the-value-of-react), highlighting the value of React's ability to render pages on the server practically for free.
## Immutable React
[Peter Hausel](http://pk11.kinja.com/) shows how to build a Wikipedia auto-complete demo based on immutable data structures (similar to [mori](https://npmjs.org/package/mori)), really taking advantage of the framework's one-way reactive data binding:
> Its truly reactive design makes DOM updates finally sane and when combined with persistent data structures one can experience JavaScript development like it was never done before.
> [Read the full post](http://tech.kinja.com/immutable-react-1495205675)
## D3 and React
[Ben Smith](http://10consulting.com/) built some great SVG-based charting components using a little less of D3 and a little more of React: [D3 and React - the future of charting components?](http://10consulting.com/2014/02/19/d3-plus-reactjs-for-charting/)
## Om and React
Josh Haberman ([@joshhaberman](https://twitter.com/JoshHaberman)) discusses performance differences between React, Om and traditional MVC frameworks in "[A closer look at OM vs React performance](http://blog.reverberate.org/2014/02/on-future-of-javascript-mvc-frameworks.html)".
Speaking of Om: [Omchaya](https://github.com/sgrove/omchaya) by Sean Grove ([@sgrove](https://twitter.com/sgrove)) is a neat Cljs/Om example project.
## Random Tweets
<div><blockquote class="twitter-tweet" lang="en"><p>Worked for 2 hours on a [@react_js](https://twitter.com/react_js) app sans internet. Love that I could get stuff done with it without googling every question.</p>&mdash; John Shimek (@varikin) <a href="https://twitter.com/varikin/status/436606891657949185">February 20, 2014</a></blockquote></div>

127
docs/acknowledgements.md Normal file
View File

@@ -0,0 +1,127 @@
---
id: acknowledgements
title: Acknowledgements
layout: single
---
We'd like to thank all of our contributors:
<div class="three-column">
<ul>
<li>Alan deLevie</li>
<li>Alex Zelenskiy</li>
<li>Alexander Solovyov</li>
<li>Andreas Svensson</li>
<li>Andrew Davey</li>
<li>Andrew Zich</li>
<li>Andrey Popp</li>
<li>Ayman Osman</li>
<li>Ben Alpert</li>
<li>Ben Newman</li>
<li>Ben Ripkens</li>
<li>Bob Eagan</li>
<li>Brian Cooke</li>
<li>Brian Kim</li>
<li>Brian Rue</li>
<li>Cam Spiers</li>
<li>Cat Chen</li>
<li>Cheng Lou</li>
<li>Christian Roman</li>
<li>Christoph Pojer</li>
<li>Clay Allsopp</li>
<li>Connor McSheffrey</li>
<li>Dan Schafer</li>
<li>Daniel Gasienica</li>
<li>Daniel Lo Nigro</li>
<li>Daniel Miladinov</li>
<li>Danny Ben-David</li>
<li>David Hellsing</li>
<li>David Hu</li>
<li>Dustin Getz</li>
<li>Eric Clemmons</li>
<li>Eric Schoffstall</li>
<li>Fabio M. Costa</li>
<li>Felipe Oliveira Carvalho</li>
<li>Felix Kling</li>
<li>Fernando Correia</li>
<li>Greg Roodt</li>
</ul>
<ul>
<li>Guido Bouman</li>
<li>Harry Hull</li>
<li>Hugo Jobling</li>
<li>Ian Obermiller</li>
<li>Ingvar Stepanyan</li>
<li>Isaac Salier-Hellendag</li>
<li>Ivan Kozik</li>
<li>Jakub Malinowski</li>
<li>James Ide</li>
<li>Jamie Wong</li>
<li>Jamison Dance</li>
<li>Jan Kassens</li>
<li>Jared Forsyth</li>
<li>Jason Bonta</li>
<li>Jason Trill</li>
<li>Jean Lauliac</li>
<li>Jeff Morrison</li>
<li>Jeffrey Lin</li>
<li>Jignesh Kakadiya</li>
<li>Johannes Baiter</li>
<li>John Watson</li>
<li>Jonas Gebhardt</li>
<li>Jonathan Hsu</li>
<li>Jordan Walke</li>
<li>Josh Duck</li>
<li>Jun Wu</li>
<li>Keito Uchiyama</li>
<li>Kit Randel</li>
<li>Kunal Mehta</li>
<li>Laurence Rowe</li>
<li>Levi McCallum</li>
<li>Logan Allen</li>
<li>Luigy Leon</li>
<li>Mark Richardson</li>
<li>Marshall Roch</li>
<li>Martin Andert</li>
<li>Martin Konicek</li>
</ul>
<ul>
<li>Mathieu M-Gosselin</li>
<li>Matt Harrison</li>
<li>Matti Nelimarkka</li>
<li>Michal Srb</li>
<li>Mouad Debbar</li>
<li>Nadeesha Cabral</li>
<li>Nicholas Bergson-Shilcock</li>
<li>Nick Gavalas</li>
<li>Nick Thompson</li>
<li>Owen Coutts</li>
<li>Pascal Hartig</li>
<li>Paul OShannessy</li>
<li>Paul Seiffert</li>
<li>Paul Shen</li>
<li>Pete Hunt</li>
<li>Peter Cottle</li>
<li>Petri Lievonen</li>
<li>Pieter Vanderwerff</li>
<li>Richard D. Worth</li>
<li>Richard Feldman</li>
<li>Richard Livesey</li>
<li>Sander Spies</li>
<li>Sean Kinsey</li>
<li>Sebastian Markbåge</li>
<li>Shaun Trennery</li>
<li>Simon Højberg</li>
<li>Stoyan Stefanov</li>
<li>Sundeep Malladi</li>
<li>Thomas Aylott</li>
<li>Timothy Yung</li>
<li>Tom Occhino</li>
<li>Vjeux</li>
<li>Wincent Colaiuta</li>
<li>Zach Bruggeman</li>
<li>imagentleman</li>
</ul>
</div>
In addition, we're grateful to [Jeff Barczewski](https://github.com/jeffbski) for allowing us to use the `react` package name on npm.

View File

@@ -20,12 +20,12 @@ sectionid: blog
<div class="pagination">
{% if paginator.previous_page %}
<a href="/react/blog/{{ paginator.previous_page_path }}" class="previous">
<a href="/react/{{ paginator.previous_page_path }}" class="previous">
&laquo; Previous Page
</a>
{% endif %}
{% if paginator.next_page %}
<a href="/react/blog/{{ paginator.next_page_path }}" class="next">
<a href="/react{{ paginator.next_page_path }}" class="next">
Next Page &raquo;
</a>
{% endif %}

View File

@@ -19,7 +19,7 @@ Let's look at a really simple example. Create a `hello-react.html` file with the
<html>
<head>
<title>Hello React</title>
<script src="http://fb.me/react-{{site.react_version}}.min.js"></script>
<script src="http://fb.me/react-{{site.react_version}}.js"></script>
<script src="http://fb.me/JSXTransformer-{{site.react_version}}.js"></script>
</head>
<body>
@@ -84,8 +84,8 @@ We've found that the best solution for this problem is to generate markup direct
**JSX lets you write JavaScript function calls with HTML syntax.** To generate a link in React using pure JavaScript you'd write: `React.DOM.a({href: 'http://facebook.github.io/react/'}, 'Hello React!')`. With JSX this becomes `<a href="http://facebook.github.io/react/">Hello React!</a>`. We've found this has made building React apps easier and designers tend to prefer the syntax, but everyone has their own workflow, so **JSX is not required to use React.**
JSX is very small; the "hello, world" example above uses every feature of JSX. To learn more about it, see [JSX in depth](./jsx-in-depth.html). Or see the transform in action in [our live JSX compiler](/react/jsx-compiler.html).
JSX is very small; the "hello, world" example above uses every feature of JSX. To learn more about it, see [JSX in depth](/react/docs/jsx-in-depth.html). Or see the transform in action in [our live JSX compiler](/react/jsx-compiler.html).
JSX is similar to HTML, but not exactly the same. See [JSX gotchas](./jsx-gotchas.html) for some key differences.
JSX is similar to HTML, but not exactly the same. See [JSX gotchas](/react/docs/jsx-gotchas.html) for some key differences.
The easiest way to get started with JSX is to use the in-browser `JSXTransformer`. We strongly recommend that you don't use this in production. You can precompile your code using our command-line [react-tools](http://npmjs.org/package/react-tools) package.

View File

@@ -10,6 +10,11 @@ next: jsx-gotchas.html
JSX is a JavaScript XML syntax transform recommended for use
with React.
> Note:
>
> Don't forget the `/** @jsx React.DOM */` pragma at the beginning of your file! This tells JSX to process the file for React.
>
> If you don't include the pragma, your source will remain untouched, so it's safe to run the JSX transformer on all JS files in your codebase if you want to.
## Why JSX?
@@ -53,9 +58,11 @@ var app = Nav({color:"blue"}, Profile(null, "click"));
```
Use the [JSX Compiler](/react/jsx-compiler.html) to try out JSX and see how it
desugars into native JavaScript.
desugars into native JavaScript, and the
[HTML to JSX converter](/react/html-jsx.html) to convert your existing HTML to
JSX.
If you want to use JSX, the [Getting Started](getting-started.html) guide shows
If you want to use JSX, the [Getting Started](/react/docs/getting-started.html) guide shows
how to setup compilation.
> Note:
@@ -92,7 +99,10 @@ var MyComponent = React.createClass({/*...*/});
var app = <MyComponent someProperty={true} />;
```
See [Multiple Components](multiple-components.html) to learn more about using composite components.
JSX will infer the component's name from the variable assignment and specify
the class's [displayName](/react/docs/component-specs.html#displayName) accordingly.
See [Multiple Components](/react/docs/multiple-components.html) to learn more about using composite components.
> Note:
>
@@ -157,19 +167,6 @@ It's easy to add comments within your JSX; they're just JS expressions:
var content = <Container>{/* this is a comment */}<Nav /></Container>;
```
## Tooling
Beyond the compilation step, JSX does not require any special tools.
* Many editors already include reasonable support for JSX (Vim, Emacs js2-mode).
* JSX syntax highlighting is available for Sublime Text and other editors
that support `*.tmLanguage` using the third-party
[`JavaScript (JSX).tmLanguage`][1].
* Linting provides accurate line numbers after compiling without sourcemaps.
* Elements use standard scoping so linters can find usage of out-of-scope
components.
[1]: https://github.com/yungsters/sublime/blob/master/tmLanguage/JavaScript%20(JSX).tmLanguage
## Prior Work
@@ -181,4 +178,4 @@ efforts include:
* JSX neither provides nor requires a runtime library.
* JSX does not alter or add to the semantics of JavaScript.
JSX is similar to HTML, but not exactly the same. See [JSX gotchas](./jsx-gotchas.html) for some key differences.
JSX is similar to HTML, but not exactly the same. See [JSX gotchas](/react/docs/jsx-gotchas.html) for some key differences.

View File

@@ -9,17 +9,9 @@ next: interactivity-and-dynamic-uis.html
JSX looks like HTML but there are some important differences you may run into.
## Whitespace Removal
JSX doesn't follow the same whitespace elimination rules as HTML. JSX removes all whitespace between two curly braces expressions. If you want to have whitespace, simply add `{' '}`.
```javascript
<div>{this.props.name} {' '} {this.props.surname}</div>
```
Follow [Issue #65](https://github.com/facebook/react/issues/65) for discussion on this behavior.
> Note:
>
> For DOM differences, such as the inline `style` attribute, check [here](/react/docs/dom-differences.html).
## HTML Entities

View File

@@ -7,7 +7,7 @@ prev: jsx-gotchas.html
next: multiple-components.html
---
You've already [learned how to display data](./displaying-data.html) with React. Now let's look at how to make our UIs interactive.
You've already [learned how to display data](/react/docs/displaying-data.html) with React. Now let's look at how to make our UIs interactive.
## A Simple Example
@@ -46,7 +46,7 @@ With React you simply pass your event handler as a camelCased prop similar to ho
If you'd like to use React on a touch device (i.e. a phone or tablet), simply call `React.initializeTouchEvents(true);` to turn them on.
## Under the Hood: autoBind and Event Delegation
## Under the Hood: Autobinding and Event Delegation
Under the hood React does a few things to keep your code performant and easy to understand.

View File

@@ -73,7 +73,7 @@ When you create a React component instance, you can include additional React com
<Parent><Child /></Parent>
```
`Parent` can read its children by accessing the special `this.props.children` prop.
`Parent` can read its children by accessing the special `this.props.children` prop. **`this.props.children` is an opaque data structure:** use the [React.Children utilities](/react/docs/top-level-api.html#react.children) to manipulate them.
### Child Reconciliation
@@ -124,7 +124,7 @@ The situation gets more complicated when the children are shuffled around (as in
var results = this.props.results;
return (
<ol>
{this.results.map(function(result) {
{results.map(function(result) {
return <li key={result.id}>{result.text}</li>;
})}
</ol>
@@ -134,6 +134,26 @@ The situation gets more complicated when the children are shuffled around (as in
When React reconciles the keyed children, it will ensure that any child with `key` will be reordered (instead of clobbered) or destroyed (instead of reused).
You can also key children by passing an object. The object keys will be used as `key` for each value. However it is important to remember that JavaScript does not guarantee the ordering of properties will be preserved. In practice browsers will preserve property order **except** for properties that can be parsed as a 32-bit unsigned integers. Numeric properties will be ordered sequentially and before other properties. If this happens React will render components out of order. This can be avoided by adding a string prefix to the key:
```javascript
render: function() {
var items = {};
this.props.results.forEach(function(result) {
// If result.id can look like a number (consider short hashes), then
// object iteration order is not guaranteed. In this case, we add a prefix
// to ensure the keys are strings.
items['result-' + result.id] = <li>{result.text}</li>;
});
return (
<ol>
{items}
</ol>
);
}
```
## Data Flow
@@ -144,7 +164,7 @@ In React, data flows from owner to owned component through `props` as discussed
You may be thinking that it's expensive to react to changing data if there are a large number of nodes under an owner. The good news is that JavaScript is fast and `render()` methods tend to be quite simple, so in most applications this is extremely fast. Additionally, the bottleneck is almost always the DOM mutation and not JS execution and React will optimize this for you using batching and change detection.
However, sometimes you really want to have fine-grained control over your performance. In that case, simply override `shouldComponentUpdate()` to return false when you want React to skip processing of a subtree. See [the React reference docs](component-specs.html) for more information.
However, sometimes you really want to have fine-grained control over your performance. In that case, simply override `shouldComponentUpdate()` to return false when you want React to skip processing of a subtree. See [the React reference docs](/react/docs/component-specs.html) for more information.
> Note:
>

View File

@@ -12,7 +12,7 @@ When designing interfaces, break down the common design elements (buttons, form
## Prop Validation
As your app grows it's helpful to ensure that your components are used correctly. We do this by allowing you to specify `propTypes`. `React.PropTypes` exports a range of validators that can be used to make sure the data you receive is valid. When an invalid value is provided for a prop, an error will be thrown. Here is an example documenting the different validators provided:
As your app grows it's helpful to ensure that your components are used correctly. We do this by allowing you to specify `propTypes`. `React.PropTypes` exports a range of validators that can be used to make sure the data you receive is valid. When an invalid value is provided for a prop, a warning will be shown in the JavaScript console. Note that for performance reasons `propTypes` is only checked in development mode. Here is an example documenting the different validators provided:
```javascript
React.createClass({
@@ -26,22 +26,48 @@ React.createClass({
optionalObject: React.PropTypes.object,
optionalString: React.PropTypes.string,
// You can ensure that your prop is limited to specific values by treating
// it as an enum.
optionalEnum: React.PropTypes.oneOf(['News','Photos']),
// Anything that can be rendered: numbers, strings, components or an array
// containing these types.
optionalRenderable: React.PropTypes.renderable,
// A React component.
optionalComponent: React.PropTypes.component,
// You can also declare that a prop is an instance of a class. This uses
// JS's instanceof operator.
someClass: React.PropTypes.instanceOf(SomeClass),
optionalMessage: React.PropTypes.instanceOf(Message),
// You can chain any of the above with isRequired to make sure an error is
// thrown if the prop isn't provided.
requiredFunc: React.PropTypes.func.isRequired
// You can ensure that your prop is limited to specific values by treating
// it as an enum.
optionalEnum: React.PropTypes.oneOf(['News', 'Photos']),
// An object that could be one of many types
optionalUnion: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.number,
React.PropTypes.instanceOf(Message)
]),
// An array of a certain type
optionalArrayOf: React.PropTypes.arrayOf(React.PropTypes.number),
// An object taking on a particular shape
optionalObjectWithShape: React.PropTypes.shape({
color: React.PropTypes.string,
fontSize: React.PropTypes.number
}),
// You can chain any of the above with isRequired to make sure a warning is
// shown if the prop isn't provided.
requiredFunc: React.PropTypes.func.isRequired,
// An object of any kind
requiredAny: React.PropTypes.any.isRequired,
// You can also specify a custom validator.
customProp: function(props, propName, componentName) {
if (!/matchme/.test(props[propName])) {
throw new Error('Validation failed!')
console.warn('Validation failed!');
}
}
},
@@ -91,12 +117,32 @@ React.renderComponent(
);
```
## Single Child
With `React.PropTypes.component` you can specify that only a single child can be passed to
a component as children.
```javascript
var MyComponent = React.createClass({
propTypes: {
children: React.PropTypes.component.isRequired
},
render: function() {
return
<div>
{this.props.children} // This must be exactly one element or it will throw.
</div>;
}
});
```
## Mixins
Components are the best way to reuse code in React, but sometimes very different components may share some common functionality. These are sometimes called [cross-cutting concerns](http://en.wikipedia.org/wiki/Cross-cutting_concern). React provides `mixins` to solve this problem.
One common use case is a component wanting to update itself on a time interval. It's easy to use `setInterval()`, but it's important to cancel your interval when you don't need it anymore to save memory. React provides [lifecycle methods](./working-with-the-browser.html) that let you know when a component is about to be created or destroyed. Let's create a simple mixin that uses these methods to provide an easy `setInterval()` function that will automatically get cleaned up when your component is destroyed.
One common use case is a component wanting to update itself on a time interval. It's easy to use `setInterval()`, but it's important to cancel your interval when you don't need it anymore to save memory. React provides [lifecycle methods](/react/docs/working-with-the-browser.html#component-lifecycle) that let you know when a component is about to be created or destroyed. Let's create a simple mixin that uses these methods to provide an easy `setInterval()` function that will automatically get cleaned up when your component is destroyed.
```javascript
/** @jsx React.DOM */

View File

@@ -87,7 +87,7 @@ If you want to initialize the component with a non-empty value, you can supply a
This example will function much like the **Controlled Components** example above.
Likewise, `<input>` supports `defaultChecked` and `<option>` supports `defaultSelected`.
Likewise, `<input>` supports `defaultChecked` and `<select>` supports `defaultValue`.
## Advanced Topics
@@ -130,3 +130,18 @@ For HTML, this easily allows developers to supply multiline values. However, sin
```
If you *do* decide to use children, they will behave like `defaultValue`.
### Why Select Value?
The selected `<option>` in an HTML `<select>` is normally specified through that option's `selected` attribute. In React, in order to make components easier to manipulate, the following format is adopted instead:
```javascript
<select value="B">
<option value="A">Apple</option>
<option value="B">Banana</option>
<option value="C">Cranberry</option>
</select>
```
To make an uncontrolled component, `defaultValue` is used instead.

View File

@@ -10,7 +10,7 @@ next: more-about-refs.html
React provides powerful abstractions that free you from touching the DOM directly in most cases, but sometimes you simply need to access the underlying API, perhaps to work with a third-party library or existing code.
## The Mock DOM
## The Virtual DOM
React is so fast because it never talks to the DOM directly. React maintains a fast in-memory representation of the DOM. `render()` methods return a *description* of the DOM, and React can diff this description with the in-memory representation to compute the fastest way to update the browser.
@@ -62,7 +62,7 @@ React.renderComponent(
## More About Refs
To learn more about refs, including ways to use them effectively, see our [more about refs](./more-about-refs.html) documentation.
To learn more about refs, including ways to use them effectively, see our [more about refs](/react/docs/more-about-refs.html) documentation.
## Component Lifecycle
@@ -80,7 +80,7 @@ React provides lifecycle methods that you can specify to hook into this process.
* `getInitialState(): object` is invoked before a component is mounted. Stateful components should implement this and return the initial state data.
* `componentWillMount()` is invoked immediately before mounting occurs.
* `componentDidMount(DOMElement rootNode)` is invoked immediately after mounting occurs. Initialization that requires DOM nodes should go here.
* `componentDidMount()` is invoked immediately after mounting occurs. Initialization that requires DOM nodes should go here.
### Updating
@@ -88,7 +88,7 @@ React provides lifecycle methods that you can specify to hook into this process.
* `componentWillReceiveProps(object nextProps)` is invoked when a mounted component receives new props. This method should be used to compare `this.props` and `nextProps` to perform state transitions using `this.setState()`.
* `shouldComponentUpdate(object nextProps, object nextState): boolean` is invoked when a component decides whether any changes warrant an update to the DOM. Implement this as an optimization to compare `this.props` with `nextProps` and `this.state` with `nextState` and return false if React should skip updating.
* `componentWillUpdate(object nextProps, object nextState)` is invoked immediately before updating occurs. You cannot call `this.setState()` here.
* `componentDidUpdate(object prevProps, object prevState, DOMElement rootNode)` is invoked immediately after updating occurs.
* `componentDidUpdate(object prevProps, object prevState)` is invoked immediately after updating occurs.
### Unmounting
@@ -103,12 +103,6 @@ _Mounted_ composite components also support the following methods:
* `getDOMNode(): DOMElement` can be invoked on any mounted component in order to obtain a reference to its rendered DOM node.
* `forceUpdate()` can be invoked on any mounted component when you know that some deeper aspect of the component's state has changed without using `this.setState()`.
> Note:
>
> The `DOMElement rootNode` argument of `componentDidMount()` and
> `componentDidUpdate()` is a convenience. The same node can be obtained by
> calling `this.getDOMNode()`.
## Browser Support and Polyfills
@@ -119,7 +113,7 @@ In addition to that philosophy, we've also taken the stance that we, as authors
### Polyfills Needed to Support Older Browsers
These six functions can be polyfilled using `es5-shim.js` from [kriskowal's es5-shim](https://github.com/kriskowal/es5-shim):
`es5-shim.js` from [kriskowal's es5-shim](https://github.com/kriskowal/es5-shim) provides the following that React needs:
* `Array.isArray`
* `Array.prototype.forEach`
@@ -127,8 +121,28 @@ These six functions can be polyfilled using `es5-shim.js` from [kriskowal's es5-
* `Array.prototype.some`
* `Date.now`
* `Function.prototype.bind`
* `Object.keys`
Other required polyfills:
`es5-sham.js`, also from [kriskowal's es5-shim](https://github.com/kriskowal/es5-shim), provides the following that React needs:
* `Object.create` Provided by `es5-sham.js` from [kriskowal's es5-shim](https://github.com/kriskowal/es5-shim).
* `console.*` Only needed when using the unminified build. If you need to polyfill this, try [paulmillr's console-polyfill](https://github.com/paulmillr/console-polyfill).
* `Object.create`
* `Object.freeze`
The unminified build of React needs the following from [paulmillr's console-polyfill](https://github.com/paulmillr/console-polyfill).
* `console.*`
When using HTML5 elements in IE8 including `<section>`, `<article>`, `<nav>`, `<header>`, and `<footer>`, it's also necessary to include [html5shiv](https://github.com/aFarkas/html5shiv) or a similar script.
### Cross-browser Issues
Although React is pretty good at abstracting browser differences, some browsers are limited or present quirky behaviors that we couldn't find a workaround for.
#### onScroll event on IE8
On IE8 the `onScroll` event doesn't bubble and IE8 doesn't have an API to define handlers to the capturing phase of an event, meaning there is no way for React to listen to these events.
Currently a handler to this event is ignored on IE8.
See the [onScroll doesn't work in IE8](https://github.com/facebook/react/issues/631) GitHub issue for more information.

View File

@@ -4,7 +4,7 @@ title: Tooling Integration
layout: docs
permalink: tooling-integration.html
prev: more-about-refs.html
next: examples.html
next: addons.html
---
Every project uses a different system for building and deploying JavaScript. We've tried to make React as environment-agnostic as possible.
@@ -38,15 +38,18 @@ If you have [npm](http://npmjs.org/), you can simply run `npm install -g react-t
### Helpful Open-Source Projects
The open-source community has built tools that integrate JSX with several build systems.
* [reactify](https://github.com/andreypopp/reactify) - use JSX with [browserify](http://browserify.org/)
* [grunt-react](https://github.com/ericclemmons/grunt-react) - [grunt](http://gruntjs.com/) task for JSX
* [require-jsx](https://github.com/seiffert/require-jsx) - use JSX with [require.js](http://requirejs.org/)
* [pyReact](https://github.com/facebook/react-python) - use JSX with [Python](http://www.python.org/)
* [react-rails](https://github.com/facebook/react-rails) - use JSX with [Ruby on Rails](http://rubyonrails.org/)
The open-source community has built tools that integrate JSX with several build systems. See [JSX integrations](/react/docs/complementary-tools.html#jsx-integrations) for the full list.
## React Page
### Syntax Highlighting & Linting
To get started on a new project, you can use [react-page](https://github.com/facebook/react-page/), a complete React project creator. It supports both server-side and client-side rendering, source transform and packaging JSX files using CommonJS modules, and instant reload.
* Many editors already include reasonable support for JSX (Vim, Emacs js2-mode).
* [JSX syntax highlighting](https://github.com/yungsters/sublime/blob/master/tmLanguage/JavaScript%20(JSX\).tmLanguage) is available for Sublime Text and other editors
that support `*.tmLanguage`.
* [web-mode.el](http://web-mode.org) is an autonomous emacs major mode that indents and highlights JSX
* Linting provides accurate line numbers after compiling without sourcemaps.
* Elements use standard scoping so linters can find usage of out-of-scope components.
### Debugging
[React Developer Tools](https://github.com/facebook/react-devtools) is a [Chrome extension](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi?hl=en) that allows you to inspect the React component hierarchy in the Chrome Developer Tools.

19
docs/docs/09-addons.md Normal file
View File

@@ -0,0 +1,19 @@
---
id: addons
title: Add-ons
layout: docs
permalink: addons.html
prev: tooling-integration.html
next: animation.html
---
`React.addons` is where we park some useful utilities for building React apps. **These should be considered experimental** but will eventually be rolled into core or a blessed utilities library:
- [`ReactTransitions`](animation.html), for dealing with animations and transitions that are usually not simple to implement, such as before a component's removal.
- [`ReactLink`](two-way-binding-helpers.html), to simplify the coordination between user's form input data and and the component's state.
- [`classSet()`](class-name-manipulation.html), for manipulating the DOM `class` string a bit more cleanly.
- [`ReactTestUtils`](test-utils.html), simple helpers for writing test cases (unminified build only).
- [`cloneWithProps()`](clone-with-props.html), to make shallow copies of React components and change their props.
- [`update()`](update.html), a helper function that makes dealing with immutable data in JavaScript easier.
To get the add-ons, use `react-with-addons.js` (and its minified counterpart) rather than the common `react.js`.

View File

@@ -1,22 +0,0 @@
---
id: examples
title: Examples
layout: docs
permalink: examples.html
prev: tooling-integration.html
---
### Production Apps
* All of [Instagram.com](http://instagram.com/) is built on React.
* Many components on [Facebook.com](http://www.facebook.com/), including the commenting interface, ads creation flows, and page insights.
* [Khan Academy](http://khanacademy.org/) is using React for its question editor.
### Sample Code
* We've included [a step-by-step comment box tutorial](./tutorial.html).
* [The React starter kit](/react/downloads.html) includes several examples which you can [view online in our GitHub repository](https://github.com/facebook/react/tree/master/examples/).
* [React Page](https://github.com/facebook/react-page) is a simple React project creator to get you up-and-running quickly with React. It supports both server-side and client-side rendering, source transform and packaging JSX files using CommonJS modules, and instant reload.
* [React one-hour email](https://github.com/petehunt/react-one-hour-email/commits/master) goes step-by-step from a static HTML mock to an interactive email reader (written in just one hour!)
* [Rendr + React app template](https://github.com/petehunt/rendr-react-template/) demonstrates how to use React's server rendering capabilities.

121
docs/docs/09.1-animation.md Normal file
View File

@@ -0,0 +1,121 @@
---
id: animation
title: Animation
layout: docs
permalink: animation.html
prev: addons.html
next: two-way-binding-helpers.html
---
React provides a `ReactTransitionGroup` addon component as a low-level API for animation, and a `ReactCSSTransitionGroup` for easily implementing basic CSS animations and transitions.
## High-level API: `ReactCSSTransitionGroup`
`ReactCSSTransitionGroup` is based on `ReactTransitionGroup` and is an easy way to perform CSS transitions and animations when a React component enters or leaves the DOM. It's inspired by the excellent [ng-animate](http://www.nganimate.org/) library.
### Getting Started
`ReactCSSTransitionGroup` is the interface to `ReactTransitions`. This is a simple element that wraps all of the components you are interested in animating. Here's an example where we fade list items in and out.
```javascript{22-24}
/** @jsx React.DOM */
var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
var TodoList = React.createClass({
getInitialState: function() {
return {items: ['hello', 'world', 'click', 'me']};
},
handleAdd: function() {
var newItems =
this.state.items.concat([prompt('Enter some text')]);
this.setState({items: newItems});
},
handleRemove: function(i) {
var newItems = this.state.items;
newItems.splice(i, 1)
this.setState({items: newItems});
},
render: function() {
var items = this.state.items.map(function(item, i) {
return (
<div key={item} onClick={this.handleRemove.bind(this, i)}>
{item}
</div>
);
}.bind(this));
return (
<div>
<div><button onClick={this.handleAdd} /></div>
<ReactCSSTransitionGroup transitionName="example">
{items}
</ReactCSSTransitionGroup>
</div>
);
}
});
```
In this component, when a new item is added to `ReactCSSTransitionGroup` it will get the `example-enter` CSS class and the `example-enter-active` CSS class added in the next tick. This is a convention based on the `transitionName` prop.
You can use these classes to trigger a CSS animation or transition. For example, try adding this CSS and adding a new list item:
```css
.example-enter {
opacity: 0.01;
transition: opacity .5s ease-in;
}
.example-enter.example-enter-active {
opacity: 1;
}
```
You'll notice that when you try to remove an item `ReactCSSTransitionGroup` keeps it in the DOM. If you're using an unminified build of React with add-ons you'll see a warning that React was expecting an animation or transition to occur. That's because `ReactCSSTransitionGroup` keeps your DOM elements on the page until the animation completes. Try adding this CSS:
```css
.example-leave {
opacity: 1;
transition: opacity .5s ease-in;
}
.example-leave.example-leave-active {
opacity: 0.01;
}
```
### Disabling Animations
You can disable animating `enter` or `leave` animations if you want. For example, sometimes you may want an `enter` animation and no `leave` animation, but `ReactCSSTransitionGroup` waits for an animation to complete before removing your DOM node. You can add `transitionEnter={false}` or `transitionLeave={false}` props to `ReactCSSTransitionGroup` to disable these animations.
## Low-level API: `ReactTransitionGroup`
`ReactTransitionGroup` is the basis for animations. When children are declaratively added or removed from it (as in the example above) special lifecycle hooks are called on them.
### `componentWillEnter(callback)`
This is called at the same time as `componentDidMount()` for components added to an existing `TransitionGroup`. It will block other animations from occurring until `callback` is called. It will not be called on the initial render of a `TransitionGroup`.
### `componentDidEnter()`
This is called after the `callback` function that was passed to `componentWillEnter` is called.
### `componentWillLeave(callback)`
This is called when the child has been removed from the `ReactTransitionGroup`. Though the child has been removed, `ReactTransitionGroup` will keep it in the DOM until `callback` is called.
### `componentDidLeave()`
This is called when the `willLeave` `callback` is called (at the same time as `componentWillUnmount`).
### Rendering a Different Component
By default `ReactTransitionGroup` renders as a `span`. You can change this behavior by providing a `component` prop. For example, here's how you would render a `<ul>`:
```javascript{1}
<ReactTransitionGroup component={React.DOM.ul}>
...
</ReactTransitionGroup>
```
Every DOM component is under `React.DOM`. However, `component` does not need to be a DOM component. It can be any React component you want; even ones you've written yourself!

View File

@@ -0,0 +1,119 @@
---
id: two-way-binding-helpers
title: Two-Way Binding Helpers
layout: docs
permalink: two-way-binding-helpers.html
prev: animation.html
next: class-name-manipulation.html
---
`ReactLink` is an easy way to express two-way binding with React.
> Note:
>
> If you're new to the framework, note that `ReactLink` is not needed for most applications and should be used cautiously.
In React, data flows one way: from owner to child. This is because data only flows one direction in [the Von Neumann model of computing](http://en.wikipedia.org/wiki/Von_Neumann_architecture). You can think of it as "one-way data binding."
However, there are lots of applications that require you to read some data and flow it back into your program. For example, when developing forms, you'll often want to update some React `state` when you receive user input. Or perhaps you want to perform layout in JavaScript and react to changes in some DOM element size.
In React, you would implement this by listening to a "change" event, read from your data source (usually the DOM) and call `setState()` on one of your components. "Closing the data flow loop" explicitly leads to more understandable and easier-to-maintain programs. See [our forms documentation](/react/docs/forms.html) for more information.
Two-way binding -- implicitly enforcing that some value in the DOM is always consistent with some React `state` -- is concise and supports a wide variety of applications. We've provided `ReactLink`: syntactic sugar for setting up the common data flow loop pattern described above, or "linking" some data source to React `state`.
> Note:
>
> ReactLink is just a thin wrapper and convention around the `onChange`/`setState()` pattern. It doesn't fundamentally change how data flows in your React application.
## ReactLink: Before and After
Here's a simple form example without using `ReactLink`:
```javascript
/** @jsx React.DOM */
var NoLink = React.createClass({
getInitialState: function() {
return {value: 'Hello!'};
},
handleChange: function(event) {
this.setState({value: event.target.value});
},
render: function() {
var value = this.state.value;
return <input type="text" value={value} onChange={this.handleChange} />;
}
});
```
This works really well and it's very clear how data is flowing, however with a lot of form fields it could get a bit verbose. Let's use `ReactLink` to save us some typing:
```javascript{4,9}
/** @jsx React.DOM */
var WithLink = React.createClass({
mixins: [React.addons.LinkedStateMixin],
getInitialState: function() {
return {value: 'Hello!'};
},
render: function() {
return <input type="text" valueLink={this.linkState('value')} />;
}
});
```
`LinkedStateMixin` adds a method to your React component called `linkState()`. `linkState()` returns a `ReactLink` object which contains the current value of the React state and a callback to change it.
`ReactLink` objects can be passed up and down the tree as props, so it's easy (and explicit) to set up two-way binding between a component deep in the hierarchy and state that lives higher in the hierarchy.
Note that `<input>` supports ReactLink for both `value` and `checked`.
## Under the Hood
There are two sides to `ReactLink`: the place where you create the `ReactLink` instance and the place where you use it. To prove how simple `ReactLink` is, let's rewrite each side separately to be more explicit.
### ReactLink Without LinkedStateMixin
```javascript{7-9,11-14}
/** @jsx React.DOM */
var WithoutMixin = React.createClass({
getInitialState: function() {
return {value: 'Hello!'};
},
handleChange: function(newValue) {
this.setState({value: newValue});
},
render: function() {
var valueLink = {
value: this.state.value,
requestChange: this.handleChange
};
return <input type="text" valueLink={valueLink} />;
}
});
```
As you can see, `ReactLink` objects are very simple objects that just have a `value` and `requestChange` prop. And `LinkedStateMixin` is similarly simple: it just populates those fields with a value from `this.state` and a callback that calls `this.setState()`.
### ReactLink Without valueLink
```javascript
/** @jsx React.DOM */
var WithoutLink = React.createClass({
mixins: [React.addons.LinkedStateMixin],
getInitialState: function() {
return {value: 'Hello!'};
},
render: function() {
var valueLink = this.linkState('value');
var handleChange = function(e) {
valueLink.requestChange(e.target.value);
};
return <input type="text" value={valueLink.value} onChange={handleChange} />;
}
});
```
The `valueLink` prop is also quite simple. It simply handles the `onChange` event and calls `this.props.valueLink.requestChange()` and also uses `this.props.valueLink.value` instead of `this.props.value`. That's it!

View File

@@ -0,0 +1,46 @@
---
id: class-name-manipulation
title: Class Name Manipulation
layout: docs
permalink: class-name-manipulation.html
prev: two-way-binding-helpers.html
next: test-utils.html
---
`classSet()` is a neat utility for easily manipulating the DOM `class` string.
Here's a common scenario and its solution without `classSet()`:
```javascript
// inside some `<Message />` React component
render: function() {
var classString = 'message';
if (this.props.isImportant) {
classString += ' message-important';
}
if (this.props.isRead) {
classString += ' message-read';
}
// 'message message-important message-read'
return <div className={classString}>Great, I'll be there.</div>;
}
```
This can quickly get tedious, as assigning class name strings can be hard to read and error-prone. `classSet()` solves this problem:
```javascript
render: function() {
var cx = React.addons.classSet;
var classes = cx({
'message': true,
'message-important': this.props.isImportant,
'message-read': this.props.isRead
});
// same final string, but much cleaner
return <div className={classes}>Great, I'll be there.</div>;
}
```
When using `classSet()`, pass an object with keys of the CSS class names you might or might not need. Truthy values will result in the key being a part of the resulting string.
No more hacky string concatenations!

View File

@@ -0,0 +1,140 @@
---
id: test-utils
title: Test Utilities
layout: docs
permalink: test-utils.html
prev: class-name-manipulation.html
next: clone-with-props.html
---
`React.addons.TestUtils` makes it easy to test React components in the testing framework of your choice (we use [Jasmine](http://pivotal.github.io/jasmine/) with [jsdom](https://github.com/tmpvar/jsdom)).
### Simulate
```javascript
Simulate.{eventName}({ReactComponent|DOMElement} element, object eventData)
```
Simulate an event dispatch on a React component instance or browser DOM node with optional `eventData` event data. **This is possibly the single most useful utility in `ReactTestUtils`.**
Example usage:
```javascript
React.addons.TestUtils.Simulate.click(myComponent);
React.addons.TestUtils.Simulate.change(myComponent);
React.addons.TestUtils.Simulate.keydown(myComponent, {key: "Enter"});
```
`Simulate` has a method for every event that React understands.
### renderIntoDocument
```javascript
ReactComponent renderIntoDocument(ReactComponent instance)
```
Render a component into a detached DOM node in the document. **This function requires a DOM.**
### mockComponent
```javascript
object mockComponent(function componentClass, string? tagName)
```
Pass a mocked component module to this method to augment it with useful methods that allow it to be used as a dummy React component. Instead of rendering as usual, the component will become a simple `<div>` (or other tag if `mockTagName` is provided) containing any provided children.
### isComponentOfType
```javascript
boolean isComponentOfType(ReactComponent instance, function componentClass)
```
Returns true if `instance` is an instance of a React `componentClass`.
### isDOMComponent
```javascript
boolean isDOMComponent(ReactComponent instance)
```
Returns true if `instance` is a DOM component (such as a `<div>` or `<span>`).
### isCompositeComponent
```javascript
boolean isCompositeComponent(ReactComponent instance)`
```
Returns true if `instance` is a composite component (created with `React.createClass()`)
### isCompositeComponentWithType
```javascript
boolean isCompositeComponentWithType(ReactComponent instance, function componentClass)
```
The combination of `isComponentOfType()` and `isCompositeComponent()`.
### isTextComponent
```javascript
boolean isTextComponent(ReactComponent instance)
```
Returns true if `instance` is a plain text component.
### findAllInRenderedTree
```javascript
array findAllInRenderedTree(ReactComponent tree, function test)
```
Traverse all components in `tree` and accumulate all components where `test(component)` is true. This is not that useful on its own, but it's used as a primitive for other test utils.
### scryRenderedDOMComponentsWithClass
```javascript
array scryRenderedDOMComponentsWithClass(ReactCompoennt tree, string className)
```
Finds all instance of components in the rendered tree that are DOM components with the class name matching `className`.
### findRenderedDOMComponentWithClass
```javascript
ReactComponent findRenderedDOMComponentWithClass(ReactComponent tree, string className)
```
Like `scryRenderedDOMComponentsWithClass()` but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
### scryRenderedDOMComponentsWithTag
```javascript
array scryRenderedDOMComponentsWithTag(ReactComponent tree, string tagName)
```
Finds all instance of components in the rendered tree that are DOM components with the tag name matching `tagName`.
### findRenderedDOMComponentWithTag
```javascript
ReactComponent findRenderedDOMComponentWithTag(ReactComponent tree, string tagName)
```
Like `scryRenderedDOMComponentsWithTag()` but expects there to be one result, and returns that one result, or throws exception if there is any other number of matches besides one.
### scryRenderedComponentsWithType
```javascript
array scryRenderedComponentsWithType(ReactComponent tree, function componentClass)
```
Finds all instances of components with type equal to `componentClass`.
### findRenderedComponentWithType
```javascript
ReactComponent findRenderedComponentWithType(ReactComponent tree, function componentClass)
```
Same as `scryRenderedComponentsWithType()` but expects there to be one result and returns that one result, or throws exception if there is any other number of matches besides one.

View File

@@ -0,0 +1,14 @@
---
id: clone-with-props
title: Cloning Components
layout: docs
permalink: clone-with-props.html
prev: test-utils.html
next: update.html
---
In rare situations a component may want to change the props of a component that it doesn't own (like changing the `className` of a component passed as `this.props.children`). Other times it may want to make multiple copies of a component passed to it. `cloneWithProps()` makes this possible.
#### `ReactComponent React.addons.cloneWithProps(ReactComponent component, object? extraProps)`
Do a shallow copy of `component` and merge any props provided by `extraProps`. Props are merged in the same manner as [`transferPropsTo()`](/react/docs/component-api.html#transferpropsto), so props like `className` will be merged intelligently.

62
docs/docs/09.6-update.md Normal file
View File

@@ -0,0 +1,62 @@
---
id: update
title: Immutability Helpers
layout: docs
permalink: update.html
prev: clone-with-props.html
---
React lets you use whatever style of data management you want, including mutation. However, if you can use immutable data in performance-critical parts of your application it's easy to implement a fast `shouldComponentUpdate()` method to significantly speed up your app.
Dealing with immutable data in JavaScript is more difficult than in languages designed for it, like [Clojure](http://clojure.org/). However, we've provided a simple immutability helper, `update()`, that makes dealing with this type of data much easier, *without* fundamentally changing how your data is represented.
## The main idea
If you mutate data like this:
```javascript
myData.x.y.z = 7;
myData.a.b.push(9);
```
you have no way of determining which data has changed since the previous copy is destroyed. Instead, you need to create a new copy of `myData` and change only the parts of it that need to be changed. Then you can compare the old copy of `myData` with the new one in `shouldComponentUpdate()` using triple-equals:
```javascript
var newData = deepCopy(myData);
newData.x.y.z = 7;
newData.a.b.push(9);
```
Unfortunately, deep copies are expensive, and sometimes impossible. You can alleviate this by only copying objects that need to be changed and by reusing the objects that haven't changed. Unfortunately, in today's JavaScript this can be cumbersome:
```javascript
var newData = extend(myData, {
x: extend(myData.x, {
y: extend(myData.x.y, {z: 7}),
}),
a: extend(myData.a, {b: myData.a.b.concat(9)})
});
```
While this is fairly performant (since it only shallow copies `log n` objects and reuses the rest), it's a big pain to write. Look at all the repetition! This is not only annoying, but also provides a large surface area for bugs.
`update() provides simple syntactic sugar around this pattern to make writing this code easier. This code becomes:
```javascript
var newData = React.addons.update(myData, {
x: {y: {z: {$set: 7}}},
a: {b: {$push: [7]}}
});
```
While the syntax takes a little getting used to (though it's inspired by [MongoDB's query language](http://docs.mongodb.org/manual/core/crud-introduction/#query)) there's no redundancy, it's statically analyzable and it's not much more typing than the mutative version.
The `$`-prefixed keys are called *directives*. The data structure they are "mutating" is called the *target*.
## Available directives
* `{$push: array}` `push()` all the items in `array` on the target
* `{$unshift: array}` `unshift()` all the items in `array` on the target
* `{$splice: array of arrays}` for each item in `array()` call `splice()` on the target with the parameters provided by the item.
* `{$set: any}` replace the target entirely
* `{$merge: object}` merge the keys of `object` with the target

View File

@@ -1,96 +0,0 @@
---
id: OUTLINE
title: Goals of the documentation
layout: docs
prev: 09.1-tutorial.html
---
- Flow of docs should mimic progression of questions a new user would ask
- High information density -- assume the reader is adept at JS
- Talk about best practices
- JSFiddles for all code samples
- Provide background for some of the design decisions
- Less words less words less words!
## Outline
Motivation / Why React?
- Declarative (simple)
- Components (separation of concerns)
- Give it 5 minutes
Displaying data
- Hello world example
- Reactive updates
- Components are just functions
- JSX syntax (link to separate doc?)
- JSX gotchas
Interactivity and dynamic UIs
- Click handler example
- Event handlers / synthetic events (link to w3c docs)
- Under the hood: autoBind and event delegation (IE8 notes)
- React is a state machine
- How state works
- What components should have state?
- What should go in state?
- What shouldn't go in state?
Scaling up: using multiple components
- Motivation: separate concerns
- Composition example
- Ownership (and owner vs. parent)
- Children
- Data flow (one-way data binding)
- A note on performance
Building effective reusable components
- You should build a reusable component library (CSS, testing etc)
- Prop validation
- Transferring props: a shortcut
- Mixins
- Testing
Forms
Working with the browser
- The mock DOM
- Refs / getDOMNode()
- More about refs
- Component lifecycle
- Browser support and polyfills
Working with your environment
- CDN-hosted React
- Using master
- In-browser JSX transform
- Productionizing: precompiled JSX
- Helpful open-source projects
Integrating with other UI libraries
- Using jQuery plugins
- Letting jQuery manage React components
- Using with Backbone.View
- CoffeeScript
- Moving from Handlebars to React: an example
Server / static rendering
- Motivation
- Simple example
- How does it work? (No DOM)
- Rendr + React
Big ideas
- Animation
- Bootstrap bindings (responsive grids)
- Reactive CSS
- Web workers
- Native views
Case studies
- Comment box tutorial from scratch
- From HTML mock to application: React one-hour email
- Jordan's LikeToggler example
Reference
- API
- DOM differences

View File

@@ -0,0 +1,60 @@
---
id: complementary-tools
title: Complementary Tools
layout: docs
permalink: complementary-tools.html
prev: videos.html
next: examples.html
---
React is a small library that does one thing well. Here's a list of tools we've found that work really well with React when building applications.
If you want your project on this list, or think one of these projects should be removed, [open an issue on GitHub](https://github.com/facebook/react/issues/new).
### JSX integrations
* **[jsxhint](https://npmjs.org/package/jsxhint)** [JSHint](http://jshint.com/) (linting) support.
* **[reactify](https://npmjs.org/package/reactify)** [Browserify](http://browserify.org/) transform.
* **[node-jsx](https://npmjs.org/package/node-jsx)** Native [Node](http://nodejs.org/) support.
* **[jsx-loader](https://npmjs.org/package/jsx-loader)** Loader for [webpack](http://webpack.github.io/).
* **[grunt-react](https://npmjs.org/package/grunt-react)** [GruntJS](http://gruntjs.com/) task.
* **[gulp-react](https://npmjs.org/package/gulp-react)** [GulpJS](http://gulpjs.com/) plugin.
* **[jsx-requirejs-plugin](https://github.com/philix/jsx-requirejs-plugin)** [RequireJS](http://requirejs.org/) plugin.
* **[react-meteor](https://github.com/benjamn/react-meteor)** [Meteor](http://www.meteor.com/) plugin.
* **[pyReact](https://github.com/facebook/react-python)** [Python](http://www.python.org/) bridge to JSX.
* **[react-rails](https://github.com/facebook/react-rails)** Ruby gem for using JSX with [Ruby on Rails](http://rubyonrails.org/).
### Full-stack starter kits
* **[react-quickstart](https://github.com/andreypopp/react-quickstart)** Quick-start template for `express`, `browserify`, `react-router-component` and `react-async` (**includes "isomorphic" server rendering**).
* **[generator-react-webpack](https://github.com/newtriks/generator-react-webpack)** [Yeoman](http://yeoman.io/) generator for React and Webpack.
* **[Genesis Skeleton](http://genesis-skeleton.com/)** Modern, opinionated, full-stack starter kit for rapid, streamlined application development (supports React).
* **[react-starter-template](https://github.com/johnthethird/react-starter-template)** Starter template with Gulp, Webpack and Bootstrap.
* **[react-brunch](https://npmjs.org/package/react-brunch)** [Brunch](http://brunch.io/) plugin.
* **[react-browserify-template](https://github.com/petehunt/react-browserify-template)** Quick-start with Browserify.
### Routing
* **[director](https://github.com/flatiron/director)** (For an example see [TodoMVC](https://github.com/tastejs/todomvc/blob/gh-pages/architecture-examples/react/js/app.jsx#L29)).
* **[Backbone](http://backbonejs.org/)** (For an example see [github-issues-viewer](https://github.com/jaredly/github-issues-viewer)).
* **[react-router](https://github.com/jaredly/react-router)** (Example coming soon).
* **[react-router-component](http://andreypopp.viewdocs.io/react-router-component)**
### Model management
* **[react.backbone](https://github.com/usepropeller/react.backbone)** Use [Backbone](http://backbonejs.org) models with React.
* **[cortex](https://github.com/mquan/cortex/)** A JavaScript library for centrally managing data with React.
* **[avers](https://github.com/wereHamster/avers)** A modern client-side model abstraction library.
### Data fetching
* **[react-async](http://andreypopp.viewdocs.io/react-async)** Adds a `getInitialStateAsync(cb)` method suitable for data fetching on both the client and the server.
* **[superagent](http://visionmedia.github.io/superagent/)** A lightweight "isomorphic" library for AJAX requests.
### UI components
* **[react-bootstrap](https://github.com/stevoland/react-bootstrap)** Bootstrap 3 components built with React.
* **[react-topcoat](https://github.com/plaxdan/react-topcoat)** Topcoat components built with React.
* **[react-lorem-component](https://github.com/martinandert/react-lorem-component)** Lorem Ipsum placeholder component.
* **[wingspan-forms](https://github.com/wingspan/wingspan-forms)** React library for dynamic forms & grids; widgets provided by KendoUI.
* **[react-translate-component](https://github.com/martinandert/react-translate-component)** React component for i18n.

28
docs/docs/examples.md Normal file
View File

@@ -0,0 +1,28 @@
---
id: examples
title: Examples
layout: docs
permalink: examples.html
prev: complementary-tools.html
---
### Production Apps
* **[Instagram.com](http://instagram.com/)** is 100% built on React, both public site and internal tools.
* **[Facebook.com](http://www.facebook.com/)**'s commenting interface, business management tools, [Lookback video editor](http://facebook.com/lookback/edit), page insights, and most, if not all, new JS development.
* **[Khan Academy](http://khanacademy.org/)** uses React for most new JS development.
* **[Sberbank](http://sberbank.ru/moscow/ru/person/)**, Russia's number one bank, is built with React.
* **[The New York Times's 2014 Red Carpet Project](http://www.nytimes.com/interactive/2014/02/02/fashion/red-carpet-project.html?_r=0)** is built with React.
### Sample Code
* **[React starter kit](/react/downloads.html)** Includes several examples which you can [view online in our GitHub repository](https://github.com/facebook/react/tree/master/examples/).
* **[React one-hour email](https://github.com/petehunt/react-one-hour-email/commits/master)** Goes step-by-step from a static HTML mock to an interactive email reader, written in just one hour!
* **[React server rendering example](https://github.com/mhart/react-server-example)** Demonstrates how to use React's server rendering capabilities.
### Open-Source Demos
* **[TodoMVC](https://github.com/tastejs/todomvc/tree/gh-pages/architecture-examples/react/js)**
* **[Khan Academy question editor](https://github.com/khan/perseus)** (Browse their GitHub account for many more production apps!)
* **[github-issue-viewer](https://github.com/jaredly/github-issues-viewer)**
* **[hn-react](https://github.com/prabirshrestha/hn-react)** Dead-simple Hacker News client.

View File

@@ -28,7 +28,7 @@ In the root directory of the starter kit, create a `helloworld.html` with the fo
<!DOCTYPE html>
<html>
<head>
<script src="build/react.min.js"></script>
<script src="build/react.js"></script>
<script src="build/JSXTransformer.js"></script>
</head>
<body>
@@ -44,7 +44,7 @@ In the root directory of the starter kit, create a `helloworld.html` with the fo
</html>
```
The XML syntax inside of JavaScript is called JSX; check out the [JSX syntax](jsx-in-depth.html) to learn more about it. In order to translate it to vanilla JavaScript we use `<script type="text/jsx">` and include `JSXTransformer.js` to actually perform the transformation in the browser.
The XML syntax inside of JavaScript is called JSX; check out the [JSX syntax](/react/docs/jsx-in-depth.html) to learn more about it. In order to translate it to vanilla JavaScript we use `<script type="text/jsx">` and include `JSXTransformer.js` to actually perform the transformation in the browser.
### Separate File
@@ -90,7 +90,7 @@ React.renderComponent(
> Note:
>
> The comment parser is very strict right now, in order for it to pick up the `@jsx` modifier, two conditions are required. The `@jsx` comment block must be the first comment on the file. The comment must start with `/**` (`/*` and `//` will not work). If the parser can't find the `@jsx` comment, it will output the file without transforming it.
> The comment parser is very strict right now; in order for it to pick up the `@jsx` modifier, two conditions are required. The `@jsx` comment block must be the first comment on the file. The comment must start with `/**` (`/*` and `//` will not work). If the parser can't find the `@jsx` comment, it will output the file without transforming it.
Update your HTML file as below:
@@ -99,7 +99,7 @@ Update your HTML file as below:
<html>
<head>
<title>Hello React!</title>
<script src="build/react.min.js"></script>
<script src="build/react.js"></script>
<!-- No need for JSXTransformer! -->
</head>
<body>
@@ -115,4 +115,4 @@ If you want to use React within a module system, [fork our repo](http://github.c
## Next Steps
Check out [the tutorial](tutorial.html) and the other examples in the `/examples` directory to learn more. Good luck, and welcome!
Check out [the tutorial](/react/docs/tutorial.html) and the other examples in the `/examples` directory to learn more. Good luck, and welcome!

View File

@@ -11,6 +11,35 @@ next: component-api.html
`React` is the entry point to the React framework. If you're using one of the prebuilt packages it's available as a global; if you're using CommonJS modules you can `require()` it.
### React.Children
`React.Children` provides utilities for dealing with the `this.props.children` opaque data structure.
#### React.Children.map
```javascript
object React.Children.map(object children, function fn [, object context])
```
Invoke `fn` on every immediate child contained within `children` with `this` set to `context`. If `children` is a nested object or array it will be traversed: `fn` will never be passed the container objects. If children is `null` or `undefined` returns `null` or `undefined` rather than an empty object.
#### React.Children.forEach
```javascript
React.Children.forEach(object children, function fn [, object context])
```
Like `React.Children.map()` but does not return an object.
#### React.Children.only
```javascript
object React.Children.only(object children)
```
Return the only child in `children`. Throws otherwise.
### React.DOM
`React.DOM` provides all of the standard HTML tags needed to build a React app. You generally don't use it directly; instead, just include it as part of the `/** @jsx React.DOM */` docblock.
@@ -31,9 +60,9 @@ Configure React's event system to handle touch events on mobile devices.
function createClass(object specification)
```
Creates a component given a specification. A component implements a `render` method which returns **one single** child. That child may have an arbitrarily deep child structure. One thing that makes components different than standard prototypal classes is that you don't need to call new on them. They are convenience wrappers that construct backing instances (via new) for you.
Create a component given a specification. A component implements a `render` method which returns **one single** child. That child may have an arbitrarily deep child structure. One thing that makes components different than standard prototypal classes is that you don't need to call new on them. They are convenience wrappers that construct backing instances (via new) for you.
For more information about the specification object, see [Component Specs and Lifecycle](component-specs.html).
For more information about the specification object, see [Component Specs and Lifecycle](/react/docs/component-specs.html).
### React.renderComponent
@@ -46,28 +75,32 @@ ReactComponent renderComponent(
)
```
Renders a React component into the DOM in the supplied `container`.
Render a React component into the DOM in the supplied `container` and return a reference to the component.
If the React component was previously rendered into `container`, this will perform an update on it and only mutate the DOM as necessary to reflect the latest React component.
If the optional callback is provided, it will be executed after the component is rendered or updated.
### React.unmountAndReleaseReactRootNode
### React.unmountComponentAtNode
```javascript
unmountAndReleaseReactRootNode(DOMElement container)
boolean unmountComponentAtNode(DOMElement container)
```
Remove a mounted React component from the DOM and clean up its event handlers and state.
Remove a mounted React component from the DOM and clean up its event handlers and state. If no component was mounted in the container, calling this function does nothing. Returns `true` if a component was unmounted and `false` if there was no component to unmount.
> Note:
>
> This method was called `React.unmountAndReleaseReactRootNode` until v0.5. It still works in v0.5 but will be removed in future versions.
### React.renderComponentToString
```javascript
renderComponentToString(ReactComponent component, function callback)
string renderComponentToString(ReactComponent component)
```
Render a component to its initial HTML. This should only be used on the server. React will call `callback` with an HTML string when the markup is ready. You can use this method to can generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.
Render a component to its initial HTML. This should only be used on the server. React will return an HTML string. You can use this method to generate HTML on the server and send the markup down on the initial request for faster page loads and to allow search engines to crawl your pages for SEO purposes.
If you call `React.renderComponent()` on a node that already has this server-rendered markup, React will preserve it and only attach event handlers, allowing you to have a very performant first-load experience.

View File

@@ -9,7 +9,7 @@ next: component-specs.html
## ReactComponent
Component classses created by `createClass()` return instances of `ReactComponent` when called. Most of the time when you're using React you're either creating or consuming these component objects.
Component classes created by `createClass()` return instances of `ReactComponent` when called. Most of the time when you're using React you're either creating or consuming these component objects.
### getDOMNode
@@ -60,7 +60,7 @@ var Avatar = React.createClass({
}
});
// <AvatarImage userId={17} width={200} height={200} />
// <Avatar userId={17} width={200} height={200} />
```
Properties that are specified directly on the target component instance (such as `src` and `userId` in the above example) will not be overwritten by `transferPropsTo`.
@@ -107,3 +107,12 @@ If your `render()` method reads from something other than `this.props` or `this.
Calling `forceUpdate()` will cause `render()` to be called on the component and its children, but React will still only update the DOM if the markup changes.
Normally you should try to avoid all uses of `forceUpdate()` and only read from `this.props` and `this.state` in `render()`. This makes your application much simpler and more efficient.
### isMounted()
```javascript
bool isMounted()
```
`isMounted()` returns true if the component is rendered into the DOM, false otherwise. You can use this method to guard asynchronous calls to `setState()` or `forceUpdate()`.

View File

@@ -20,7 +20,7 @@ ReactComponent render()
The `render()` method is required.
When called, it should examine `this.props` and `this.state` and return a single child component. This child component can be either a native DOM component (such as `<div>`) or another composite component that you've defined yourself.
When called, it should examine `this.props` and `this.state` and return a single child component. This child component can be either a virtual representation of a native DOM component (such as `<div />` or `React.DOM.div()`) or another composite component that you've defined yourself.
The `render()` function should be *pure*, meaning that it does not modify component state, it returns the same result each time it's invoked, and it does not read from or write to the DOM or otherwise interact with the browser (e.g., by using `setTimeout`). If you need to interact with the browser, perform your work in `componentDidMount()` or the other lifecycle methods instead. Keeping `render()` pure makes server rendering more practical and makes components easier to think about.
@@ -31,7 +31,7 @@ The `render()` function should be *pure*, meaning that it does not modify compon
object getInitialState()
```
Invoked once when the component is mounted. The return value will be used as the initial value of `this.state`.
Invoked once before the component is mounted. The return value will be used as the initial value of `this.state`.
### getDefaultProps
@@ -51,7 +51,7 @@ This method is invoked before `getInitialState` and therefore cannot rely on `th
object propTypes
```
The `propTypes` object allows you to validate props being passed to your components. For more information about `propTypes`, see [Reusable Components](reusable-components.html).
The `propTypes` object allows you to validate props being passed to your components. For more information about `propTypes`, see [Reusable Components](/react/docs/reusable-components.html).
<!-- TODO: Document propTypes here directly. -->
@@ -62,11 +62,45 @@ The `propTypes` object allows you to validate props being passed to your compone
array mixins
```
The `mixins` array allows you to use mixins to share behavior among multiple components. For more information about mixins, see [Reusable Components](reusable-components.html).
The `mixins` array allows you to use mixins to share behavior among multiple components. For more information about mixins, see [Reusable Components](/react/docs/reusable-components.html).
<!-- TODO: Document mixins here directly. -->
### statics
```javascript
object statics
```
The `statics` object allows you to define static methods that can be called on the component class. For example:
```javascript
var MyComponent = React.createClass({
statics: {
customMethod: function(foo) {
return foo === 'bar';
}
},
render: function() {
}
});
MyComponent.customMethod('bar'); // true
```
Methods defined within this block are _static_, meaning that you can run them before any component instances are created, and the methods do not have access to the props or state of your components. If you want to check the value of props in a static method, have the caller pass in the props as an argument to the static method.
### displayName
```javascript
string displayName
```
The `displayName` string is used in debugging messages. JSX sets this value automatically, see [JSX in Depth](/react/docs/jsx-in-depth.html#react-composite-components).
## Lifecycle Methods
Various methods are executed at specific points in a component's lifecycle.
@@ -78,19 +112,23 @@ Various methods are executed at specific points in a component's lifecycle.
componentWillMount()
```
Invoked immediately before rendering occurs. If you call `setState` within this method, `render()` will see the updated state and will be executed only once despite the state change.
Invoked once, immediately before the initial rendering occurs. If you call `setState` within this method, `render()` will see the updated state and will be executed only once despite the state change.
### Mounting: componentDidMount
```javascript
componentDidMount(DOMElement rootNode)
componentDidMount()
```
Invoked immediately after rendering occurs. At this point in the lifecycle, the component has a DOM representation which you can access via the `rootNode` argument or by calling `this.getDOMNode()`.
Invoked immediately after rendering occurs. At this point in the lifecycle, the component has a DOM representation which you can access via `this.getDOMNode()`.
If you want to integrate with other JavaScript frameworks, set timers using `setTimeout` or `setInterval`, or send AJAX requests, perform those operations in this method.
> Note:
>
> Prior to v0.9, the DOM node was passed in as the last argument. If you were using this, you can still access the DOM node by calling `this.getDOMNode()`.
### Updating: componentWillReceiveProps
@@ -157,13 +195,17 @@ Use this as an opportunity to perform preparation before an update occurs.
### Updating: componentDidUpdate
```javascript
componentDidUpdate(object prevProps, object prevState, DOMElement rootNode)
componentDidUpdate(object prevProps, object prevState)
```
Invoked immediately after updating occurs. This method is not called for the initial render.
Use this as an opportunity to operate on the DOM when the component has been updated.
> Note:
>
> Prior to v0.9, the DOM node was passed in as the last argument. If you were using this, you can still access the DOM node by calling `this.getDOMNode()`.
### Unmounting: componentWillUnmount

View File

@@ -11,11 +11,10 @@ next: events.html
React attempts to support all common elements. If you need an element that isn't listed here, please file an issue.
The following elements are supported:
### HTML Elements
The following HTML elements are supported:
```
a abbr address area article aside audio b base bdi bdo big blockquote body br
button canvas caption cite code col colgroup data datalist dd del details dfn
@@ -29,37 +28,50 @@ thead time title tr track u ul var video wbr
### SVG elements
The following SVG elements are supported:
```
circle g line path polyline rect svg text
circle defs g line linearGradient path polygon polyline radialGradient rect
stop svg text
```
You may also be interested in [react-art](https://github.com/facebook/react-art), a drawing library for React that can render to Canvas, SVG, or VML (for IE8).
## Supported Attributes
React supports all `data-*` and `aria-*` attributes as well as every attribute
in the following lists. Note that all attributes are camel-cased and the attributes `class` and `for` are `className` and `htmlFor`, respectively, to match the DOM API specification.
React supports all `data-*` and `aria-*` attributes as well as every attribute in the following lists.
For a list of events, see [Supported Events](events.html).
> Note:
>
> All attributes are camel-cased and the attributes `class` and `for` are `className` and `htmlFor`, respectively, to match the DOM API specification.
For a list of events, see [Supported Events](/react/docs/events.html).
### HTML Attributes
These standard attributes are supported:
```
accessKey accept action ajaxify allowFullScreen allowTransparency alt
accept accessKey action allowFullScreen allowTransparency alt async
autoComplete autoFocus autoPlay cellPadding cellSpacing charSet checked
className colSpan content contentEditable contextMenu controls data dateTime
dir disabled draggable encType form frameBorder height hidden href htmlFor
httpEquiv icon id label lang list max maxLength method min multiple name
pattern poster preload placeholder radioGroup rel readOnly required role
rowSpan scrollLeft scrollTop selected size spellCheck src step style tabIndex
target title type value width wmode
className colSpan cols content contentEditable contextMenu controls data
dateTime defer dir disabled draggable encType form formNoValidate frameBorder
height hidden href htmlFor httpEquiv icon id label lang list loop max
maxLength method min multiple name noValidate pattern placeholder poster
preload radioGroup readOnly rel required role rowSpan rows sandbox scope
scrollLeft scrollTop seamless selected size span spellCheck src srcDoc step
style tabIndex target title type value width wmode
```
In addition, the non-standard `autoCapitalize` attribute is supported for Mobile Safari.
In addition, the non-standard `autoCapitalize` and `autoCorrect` attributes are supported for Mobile Safari, and the `property` attribute is supported for Open Graph `<meta>` tags.
There is also the React-specific attribute `dangerouslySetInnerHTML` ([more here](/react/docs/special-non-dom-attributes.html)), used for directly inserting HTML strings into a component.
### SVG Attributes
```
cx cy d fill fx fy points r stroke strokeLinecap strokeWidth transform x x1 x2
version viewBox y y1 y2 spreadMethod offset stopColor stopOpacity
gradientUnits gradientTransform
cx cy d fill fx fy gradientTransform gradientUnits offset points r rx ry
spreadMethod stopColor stopOpacity stroke strokeLinecap strokeWidth textAnchor transform
version viewBox x1 x2 x y1 y2 y
```

View File

@@ -62,14 +62,16 @@ Properties:
```javascript
boolean altKey
String char
boolean ctrlKey
Number charCode
String key
Number keyCode
String locale
Number location
boolean metaKey
boolean repeat
boolean shiftKey
Number which
```
@@ -96,7 +98,7 @@ Event names:
onChange onInput onSubmit
```
For more information about the onChange event, see [Forms](forms.html).
For more information about the onChange event, see [Forms](/react/docs/forms.html).
### Mouse Events
@@ -106,7 +108,7 @@ Event names:
```
onClick onDoubleClick onDrag onDragEnd onDragEnter onDragExit onDragLeave
onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave
onMouseMove onMouseUp
onMouseMove onMouseOut onMouseOver onMouseUp
```
Properties:
@@ -128,25 +130,6 @@ boolean shiftKey
```
### Mutation Events
Event names:
```
onDOMCharacterDataModified
```
Properties:
```javascript
Number attrChange
String attrName
String newValue
String prevValue
Node relatedNode
```
### Touch events
To enable touch events, call `React.initializeTouchEvents(true)` before

View File

@@ -4,11 +4,13 @@ title: DOM Differences
layout: docs
permalink: dom-differences.html
prev: events.html
next: special-non-dom-attributes.html
---
React has implemented a browser-independent events and DOM system for performance and cross-browser compatibility reasons. We took the opportunity to clean up a few rough edges in browser DOM implementations.
* All DOM properties and attributes (including event handlers) should be camelCased to be consistent with standard JavaScript style. We intentionally break with the spec here since the spec is inconsistent.
* All DOM properties and attributes (including event handlers) should be camelCased to be consistent with standard JavaScript style. We intentionally break with the spec here since the spec is inconsistent. **However**, `data-*` and `aria-*` attributes [conform to the specs](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#data-*) and should be lower-cased only.
* The `style` attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM `style` JavaScript property, is more efficient, and prevents XSS security holes.
* All event objects conform to the W3C spec, and all events (including submit) bubble correctly per the W3C spec. See [Event System](events.html) for more details.
* The `onChange` event behaves as you would expect it to: whenever a form field is changed this event is fired rather than inconsistently on blur. We intentionally break from existing browser behavior because `onChange` is a misnomer for its behavior and React relies on this event to react to user input in real time. See [Forms](forms.html) for more details.
* All event objects conform to the W3C spec, and all events (including submit) bubble correctly per the W3C spec. See [Event System](/react/docs/events.html) for more details.
* The `onChange` event behaves as you would expect it to: whenever a form field is changed this event is fired rather than inconsistently on blur. We intentionally break from existing browser behavior because `onChange` is a misnomer for its behavior and React relies on this event to react to user input in real time. See [Forms](/react/docs/forms.html) for more details.
* Form input attributes such as `value` and `checked`, as well as `textarea`. [More here](/react/docs/forms.html).

View File

@@ -0,0 +1,14 @@
---
id: special-non-dom-attributes
title: Special Non-DOM Attributes
layout: docs
permalink: special-non-dom-attributes.html
prev: dom-differences.html
next: reconciliation.html
---
Beside [DOM differences](/react/docs/dom-differences.html), React offers some attributes that simply don't exist in DOM.
- `key`: an optional, unique identifier. When your component shuffles around during `render` passes, it might be destroyed and recreated due to the diff algorithm. Assigning it a key that persists makes sure the component stays. See more [here](/react/docs/multiple-components.html#dynamic-children).
- `ref`: see [here](/react/docs/more-about-refs.html).
- `dangerouslySetInnerHTML`: takes an object with the key `__html` and a DOM string as value. This is mainly for cooperating with DOM string manipulation libraries. Refer to the last example on the front page.

View File

@@ -0,0 +1,133 @@
---
id: reconciliation
title: Reconciliation
layout: docs
permalink: reconciliation.html
prev: special-non-dom-attributes.html
---
React key design decision is to make the API seem like it re-renders the whole app on every update. This makes writing applications a lot easier but is also an incredible challenge to make it tractable. This article explains how with powerful heuristics we managed to turn a O(n<sup>3</sup>) problem into a O(n) one.
## Motivation
Generating the minimum number of operations to transform one tree into another is a complex and well-studied problem. The [state of the art algorithms](http://grfia.dlsi.ua.es/ml/algorithms/references/editsurvey_bille.pdf) have a complexity in the order of O(n<sup>3</sup>) where n is the number of nodes in the tree.
This means that displaying 1000 nodes would require in the order of one billion comparisons. This is far too expensive for our use case. To put this number in perspective, CPUs nowadays execute roughly 3 billion instruction per second. So even with the most performant implementation, we wouldn't be able to compute that diff in less than a second.
Since an optimal algorithm is not tractable, we implement a non-optimal O(n) algorithm using heuristics based on two assumptions:
1. Two components of the same class will generate similar trees and two components of different classes will generate different trees.
2. It is possible to provide a unique key for elements that is stable across different renders.
In practice, these assumptions are ridiculously fast for almost all practical use cases.
## Pair-wise diff
In order to do a tree diff, we first need to be able to diff two nodes. There are three different cases being handled.
### Different Node Types
If the node type is different, React is going to treat them as two different sub-trees, throw away the first one and build/insert the second one.
```xml
renderA: <div />
renderB: <span />
=> [removeNode <div />], [insertNode <span />]
```
The same logic is used for custom components. If they are not of the same type, React is not going to even try at matching what they render. It is just going to remove the first one from the DOM and insert the second one.
```xml
renderA: <Header />
renderB: <Content />
=> [removeNode <Header />], [insertNode <Content />]
```
Having this high level knowledge is a very important aspect of why React diff algorithm is both fast and precise. It provides a good heuristic to quickly prune big parts of the tree and focus on parts likely to be similar.
It is very unlikely that a `<Header>` element is going generate a DOM that is going to look like what a `<Content>` would generate. Instead of spending time trying to match those two structures, React just re-builds the tree from scratch.
As a corollary, if there is a `<Header>` element at the same position in two consecutive renders, you would expect to see a very similar structure and it is worth exploring it.
### DOM Nodes
When comparing two DOM nodes, we look at the attributes of both and can decide which of them changed in linear time.
```xml
renderA: <div id="before" />
renderB: <div id="after" />
=> [replaceAttribute id "after"]
```
Instead of treating style as an opaque string, a key-value object is used instead. This lets us update only the properties that changed.
```xml
renderA: <div style={{'{{'}}color: 'red'}} />
renderB: <div style={{'{{'}}fontWeight: 'bold'}} />
=> [removeStyle color], [addStyle font-weight 'bold']
```
After the attributes have been updated, we recurse on all the children.
### Custom Components
We decided that the two custom components are the same. Since components are stateful, we cannot just use the new component and call it a day. React takes all the attributes from the new component and call `component[Will/Did]ReceiveProps()` on the previous one.
The previous component is now operational. Its `render()` method is called and the diff algorithm restarts with the new result and the previous result.
## List-wise diff
### Problematic Case
In order to do children reconciliation, React adopts a very naive approach. It goes over the list of children both at the same time and whenever there's a difference generates a mutation.
For example if you add an element at the end:
```xml
renderA: <div><span>first</span></div>
renderB: <div><span>first</span><span>second</span></div>
=> [insertNode <span>second</span>]
```
Inserting an element at the beginning is problematic. React is going to see that both nodes are spans and therefore run into a mutation mode.
```xml
renderA: <div><span>first</span></div>
renderB: <div><span>second</span><span>first</span></div>
=> [replaceAttribute textContent 'second'], [insertNode <span>first</span>]
```
There are many algorithms that attempt to find the minimum sets of operations to transform a list of elements. [Levenshtein distance](http://en.wikipedia.org/wiki/Levenshtein_distance) can find the minimum using single element insertion, deletion and substitution in O(n<sup>2</sup>). Even if we were to use Levenshtein, this doesn't find when a node has moved into another position and algorithms to do that have much worse complexity.
### Keys
In order to solve this seemingly intractable issue, an optional attribute has been introduced. You can provide for each child a key that is going to be used to do the matching. If you specify a key, React is now able to find insertion, deletion, substitution and moves in O(n) using a hash table.
```xml
renderA: <div><span key="first">first</span></div>
renderB: <div><span key="second">second</span><span key="first">first</span></div>
=> [insertNode <span>second</span>]
```
In practice, finding a key is not really hard. Most of the time, the element you are going to display already have a unique id. When it is not the case, you can hash some parts of the content to generate an id. Remember that the id only has to be unique among its sibling, not globally unique.
## Trade-offs
It is important to remember that the reconciliation algorithm is an implementation detail. React could re-render the whole app on every action, the end-result would be the same. We are regularly refining the heuristics in order to make common use cases faster.
In the current implementation, you can express the fact that a sub-tree has been moved between siblings, but you cannot tell that it has moved somewhere else. The algorithm will re-render that full sub-tree.
Because we rely on two heuristics, if the assumptions behind them are not met, performance will suffer.
1. The algorithm will not try to match sub-trees of different components classes. If you see yourself alternating between two components classes with very similar output, you may want to make it the same class. In practice, we haven't found this to be an issue.
2. If you don't provide stable keys (by using Math.random() for example), all the sub-trees are going to be re-rendered every single time. By giving the users the choice to chose the key, they have the ability to shoot themselves in the foot.

View File

@@ -0,0 +1,147 @@
---
id: thinking-in-react
title: Thinking in React
layout: docs
prev: tutorial.html
next: videos.html
---
This was originally a [blog post](/react/blog/2013/11/05/thinking-in-react.html) from the [official React blog](/react/blog).
React is, in my opinion, the premier way to build big, fast Web apps with JavaScript. It's scaled very well for us at Facebook and Instagram.
One of the many great parts of React is how it makes you think about apps as you build them. In this post I'll walk you through the thought process of building a searchable product data table using React.
## Start with a mock
Imagine that we already have a JSON API and a mock from our designer. Our designer apparently isn't very good because the mock looks like this:
![Mockup](/react/img/blog/thinking-in-react-mock.png)
Our JSON API returns some data that looks like this:
```
[
{category: "Sporting Goods", price: "$49.99", stocked: true, name: "Football"},
{category: "Sporting Goods", price: "$9.99", stocked: true, name: "Baseball"},
{category: "Sporting Goods", price: "$29.99", stocked: false, name: "Basketball"},
{category: "Electronics", price: "$99.99", stocked: true, name: "iPod Touch"},
{category: "Electronics", price: "$399.99", stocked: false, name: "iPhone 5"},
{category: "Electronics", price: "$199.99", stocked: true, name: "Nexus 7"}
];
```
## Step 1: break the UI into a component hierarchy
The first thing you'll want to do is to draw boxes around every component (and subcomponent) in the mock and give them all names. If you're working with a designer they may have already done this, so go talk to them! Their Photoshop layer names may end up being the names of your React components!
But how do you know what should be its own component? Just use the same techniques for deciding if you should create a new function or object. One such technique is the [single responsibility principle](http://en.wikipedia.org/wiki/Single_responsibility_principle), that is, a component should ideally only do one thing. If it ends up growing it should be decomposed into smaller subcomponents.
Since you're often displaying a JSON data model to a user, you'll find that if your model was built correctly your UI (and therefore your component structure) will map nicely onto it. That's because user interfaces and data models tend to adhere to the same *information architecture* which means the work of separating your UI into components is often trivial. Just break it up into components that represent exactly one piece of your data model.
![Component diagram](/react/img/blog/thinking-in-react-components.png)
You'll see here that we have five components in our simple app. I've italicized the data each component represents.
1. **`FilterableProductTable` (orange):** contains the entirety of the example
2. **`SearchBar` (blue):** receives all *user input*
3. **`ProductTable` (green):** displays and filters the *data collection* based on *user input*
4. **`ProductCategoryRow` (turquoise):** displays a heading for each *category*
5. **`ProductRow` (red):** displays a row for each *product*
If you look at `ProductTable` you'll see that the table header (containing the "Name" and "Price" labels) isn't its own component. This is a matter of preference and there's an argument to be made either way. For this example I left it as part of `ProductTable` because it is part of rendering the *data collection* which is `ProductTable`'s responsibility. However if this header grows to be complex (i.e. if we were to add affordances for sorting) it would certainly make sense to make this its own `ProductTableHeader` component.
Now that we've identified the components in our mock, let's arrange them into a hierarchy. This is easy. Components that appear within another component in the mock should appear as a child in the hierarchy:
* `FilterableProductTable`
* `SearchBar`
* `ProductTable`
* `ProductCategoryRow`
* `ProductRow`
## Step 2: Build a static version in React
<iframe width="100%" height="300" src="http://jsfiddle.net/6wQMG/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
Now that you have your component hierarchy it's time to start implementing your app. The easiest way is to build a version that takes your data model and renders the UI but has no interactivity. It's easiest to decouple these processes because building a static version requires a lot of typing and no thinking, and adding interactivity requires a lot of thinking and not a lot of typing. We'll see why.
To build a static version of your app that renders your data model you'll want to build components that reuse other components and pass data using *props*. *props* are a way of passing data from parent to child. If you're familiar with the concept of *state*, **don't use state at all** to build this static version. State is reserved only for interactivity, that is, data that changes over time. Since this is a static version of the app you don't need it.
You can build top-down or bottom-up. That is, you can either start with building the components higher up in the hierarchy (i.e. starting with `FilterableProductTable`) or with the ones lower in it (`ProductRow`). In simpler examples it's usually easier to go top-down and on larger projects it's easier to go bottom-up and write tests as you build.
At the end of this step you'll have a library of reusable components that render your data model. The components will only have `render()` methods since this is a static version of your app. The component at the top of the hierarchy (`FilterableProductTable`) will take your data model as a prop. If you make a change to your underlying data model and call `renderComponent()` again the UI will be updated. It's easy to see how your UI is updated and where to make changes since there's nothing complicated going on since React's **one-way data flow** (also called *one-way binding*) keeps everything modular, easy to reason about, and fast.
Simply refer to the [React docs](http://facebook.github.io/react/docs/) if you need help executing this step.
### A brief interlude: props vs state
There are two types of "model" data in React: props and state. It's important to understand the distinction between the two; skim [the official React docs](http://facebook.github.io/react/docs/interactivity-and-dynamic-uis.html) if you aren't sure what the difference is.
## Step 3: Identify the minimal (but complete) representation of UI state
To make your UI interactive you need to be able to trigger changes to your underlying data model. React makes this easy with **state**.
To build your app correctly you first need to think of the minimal set of mutable state that your app needs. The key here is DRY: *Don't Repeat Yourself*. Figure out what the absolute minimal representation of the state of your application needs to be and compute everything else you need on-demand. For example, if you're building a TODO list, just keep an array of the TODO items around; don't keep a separate state variable for the count. Instead, when you want to render the TODO count simply take the length of the TODO items array.
Think of all of the pieces of data in our example application. We have:
* The original list of products
* The search text the user has entered
* The value of the checkbox
* The filtered list of products
Let's go through each one and figure out which one is state. Simply ask three questions about each piece of data:
1. Is it passed in from a parent via props? If so, it probably isn't state.
2. Does it change over time? If not, it probably isn't state.
3. Can you compute it based on any other state or props in your component? If so, it's not state.
The original list of products is passed in as props, so that's not state. The search text and the checkbox seem to be state since they change over time and can't be computed from anything. And finally, the filtered list of products isn't state because it can be computed by combining the original list of products with the search text and value of the checkbox.
So finally, our state is:
* The search text the user has entered
* The value of the checkbox
## Step 4: Identify where your state should live
<iframe width="100%" height="300" src="http://jsfiddle.net/QvHnx/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
OK, so we've identified what the minimal set of app state is. Next we need to identify which component mutates, or *owns*, this state.
Remember: React is all about one-way data flow down the component hierarchy. It may not be immediately clear which component should own what state. **This is often the most challenging part for newcomers to understand,** so follow these steps to figure it out:
For each piece of state in your application:
* Identify every component that renders something based on that state.
* Find a common owner component (a single component above all the components that need the state in the hierarchy).
* Either the common owner or another component higher up in the hierarchy should own the state.
* If you can't find a component where it makes sense to own the state, create a new component simply for holding the state and add it somewhere in the hierarchy above the common owner component.
Let's run through this strategy for our application:
* `ProductTable` needs to filter the product list based on state and `SearchBar` needs to display the search text and checked state.
* The common owner component is `FilterableProductTable`.
* It conceptually makes sense for the filter text and checked value to live in `FilterableProductTable`
Cool, so we've decided that our state lives in `FilterableProductTable`. First, add a `getInitialState()` method to `FilterableProductTable` that returns `{filterText: '', inStockOnly: false}` to reflect the initial state of your application. Then pass `filterText` and `inStockOnly` to `ProductTable` and `SearchBar` as a prop. Finally, use these props to filter the rows in `ProductTable` and set the values of the form fields in `SearchBar`.
You can start seeing how your application will behave: set `filterText` to `"ball"` and refresh your app. You'll see the data table is updated correctly.
## Step 5: Add inverse data flow
<iframe width="100%" height="300" src="http://jsfiddle.net/3Vs3Q/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
So far we've built an app that renders correctly as a function of props and state flowing down the hierarchy. Now it's time to support data flowing the other way: the form components deep in the hierarchy need to update the state in `FilterableProductTable`.
React makes this data flow explicit to make it easy to understand how your program works, but it does require a little more typing than traditional two-way data binding. React provides an add-on called `ReactLink` to make this pattern as convenient as two-way binding, but for the purpose of this post we'll keep everything explicit.
If you try to type or check the box in the current version of the example you'll see that React ignores your input. This is intentional, as we've set the `value` prop of the `input` to always be equal to the `state` passed in from `FilterableProductTable`.
Let's think about what we want to happen. We want to make sure that whenever the user changes the form we update the state to reflect the user input. Since components should only update their own state, `FilterableProductTable` will pass a callback to `SearchBar` that will fire whenever the state should be updated. We can use the `onChange` event on the inputs to be notified of it. And the callback passed by `FilterableProductTable` will call `setState()` and the app will be updated.
Though this sounds like a lot it's really just a few lines of code. And it's really explicit how your data is flowing throughout the app.
## And that's it
Hopefully this gives you an idea of how to think about building components and applications with React. While it may be a little more typing than you're used to, remember that code is read far more than it's written, and it's extremely easy to read this modular, explicit code. As you start to build large libraries of components you'll appreciate this explicitness and modularity, and with code reuse your lines of code will start to shrink :)

View File

@@ -2,8 +2,11 @@
id: tutorial
title: Tutorial
layout: docs
prev: getting-started.html
next: thinking-in-react.html
---
We'll be building a simple, but realistic comments box that you can drop into a blog, similar to Disqus, LiveFyre or Facebook comments.
We'll be building a simple, but realistic comments box that you can drop into a blog, a basic version of the realtime comments offered by Disqus, LiveFyre or Facebook comments.
We'll provide:
@@ -32,6 +35,7 @@ For this tutorial we'll use prebuilt JavaScript files on a CDN. Open up your fav
<title>Hello React</title>
<script src="http://fb.me/react-{{site.react_version}}.js"></script>
<script src="http://fb.me/JSXTransformer-{{site.react_version}}.js"></script>
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
</head>
<body>
<div id="content"></div>
@@ -39,6 +43,7 @@ For this tutorial we'll use prebuilt JavaScript files on a CDN. Open up your fav
/**
* @jsx React.DOM
*/
// The above declaration must remain intact at the top of the script.
// Your code here
</script>
</body>
@@ -65,7 +70,7 @@ Let's build the `CommentBox` component, which is just a simple `<div>`:
var CommentBox = React.createClass({
render: function() {
return (
<div class="commentBox">
<div className="commentBox">
Hello, world! I am a CommentBox.
</div>
);
@@ -99,7 +104,7 @@ React.renderComponent(
);
```
Its use is optional but we've found JSX syntax easier to use than plain JavaScript. Read more on the [JSX Syntax article](jsx-in-depth.html).
Its use is optional but we've found JSX syntax easier to use than plain JavaScript. Read more on the [JSX Syntax article](/react/docs/jsx-in-depth.html).
#### What's going on
@@ -120,7 +125,7 @@ Let's build skeletons for `CommentList` and `CommentForm` which will, again, be
var CommentList = React.createClass({
render: function() {
return (
<div class="commentList">
<div className="commentList">
Hello, world! I am a CommentList.
</div>
);
@@ -130,7 +135,7 @@ var CommentList = React.createClass({
var CommentForm = React.createClass({
render: function() {
return (
<div class="commentForm">
<div className="commentForm">
Hello, world! I am a CommentForm.
</div>
);
@@ -145,7 +150,7 @@ Next, update the `CommentBox` component to use its new friends:
var CommentBox = React.createClass({
render: function() {
return (
<div class="commentBox">
<div className="commentBox">
<h1>Comments</h1>
<CommentList />
<CommentForm />
@@ -166,7 +171,7 @@ Let's create our third component, `Comment`. We will want to pass it the author
var CommentList = React.createClass({
render: function() {
return (
<div class="commentList">
<div className="commentList">
<Comment author="Pete Hunt">This is one comment</Comment>
<Comment author="Jordan Walke">This is *another* comment</Comment>
</div>
@@ -186,8 +191,8 @@ Let's create the Comment component. It will read the data passed to it from the
var Comment = React.createClass({
render: function() {
return (
<div class="comment">
<h2 class="commentAuthor">
<div className="comment">
<h2 className="commentAuthor">
{this.props.author}
</h2>
{this.props.children}
@@ -205,12 +210,13 @@ Markdown is a simple way to format your text inline. For example, surrounding te
First, add the third-party **Showdown** library to your application. This is a JavaScript library which takes Markdown text and converts it to raw HTML. This requires a script tag in your head (which we have already included in the React playground):
```html{6}
```html{7}
<!-- template.html -->
<head>
<title>Hello React</title>
<script src="http://fb.me/react-{{site.react_version}}.js"></script>
<script src="http://fb.me/JSXTransformer-{{site.react_version}}.js"></script>
<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script>
</head>
```
@@ -223,8 +229,8 @@ var converter = new Showdown.converter();
var Comment = React.createClass({
render: function() {
return (
<div class="comment">
<h2 class="commentAuthor">
<div className="comment">
<h2 className="commentAuthor">
{this.props.author}
</h2>
{converter.makeHtml(this.props.children.toString())}
@@ -247,8 +253,8 @@ var Comment = React.createClass({
render: function() {
var rawMarkup = converter.makeHtml(this.props.children.toString());
return (
<div class="comment">
<h2 class="commentAuthor">
<div className="comment">
<h2 className="commentAuthor">
{this.props.author}
</h2>
<span dangerouslySetInnerHTML={{"{{"}}__html: rawMarkup}} />
@@ -281,7 +287,7 @@ We need to get this data into `CommentList` in a modular way. Modify `CommentBox
var CommentBox = React.createClass({
render: function() {
return (
<div class="commentBox">
<div className="commentBox">
<h1>Comments</h1>
<CommentList data={this.props.data} />
<CommentForm />
@@ -298,7 +304,7 @@ React.renderComponent(
Now that the data is available in the `CommentList`, let's render the comments dynamically:
```javascript{4-6}
```javascript{4-6,9}
// tutorial10.js
var CommentList = React.createClass({
render: function() {
@@ -306,7 +312,7 @@ var CommentList = React.createClass({
return <Comment author={comment.author}>{comment.text}</Comment>;
});
return (
<div class="commentList">
<div className="commentList">
{commentNodes}
</div>
);
@@ -320,7 +326,7 @@ That's it!
Let's replace the hard-coded data with some dynamic data from the server. We will remove the data prop and replace it with a URL to fetch:
```javascript{2}
```javascript{3}
// tutorial11.js
React.renderComponent(
<CommentBox url="comments.json" />,
@@ -346,7 +352,7 @@ var CommentBox = React.createClass({
},
render: function() {
return (
<div class="commentBox">
<div className="commentBox">
<h1>Comments</h1>
<CommentList data={this.state.data} />
<CommentForm />
@@ -369,27 +375,31 @@ When the component is first created, we want to GET some JSON from the server an
]
```
We will use jQuery 1.5 to help make an asynchronous request to the server.
We'll use jQuery to help make an asynchronous request to the server.
Note: because this is becoming an AJAX application you'll need to develop your app using a web server rather than as a file sitting on your file system. The easiest way to do this is to run `python -m SimpleHTTPServer` in your application's directory.
```javascript{4-11}
```javascript{6-17}
// tutorial13.js
var CommentBox = React.createClass({
getInitialState: function() {
return {data: []};
},
componentWillMount: function() {
$.ajax({
url: 'comments.json',
url: this.props.url,
dataType: 'json',
mimeType: 'textPlain',
success: function(data) {
this.setState({data: data});
}.bind(this),
error: function(xhr, status, err) {
console.error(this.props.url, status, err.toString());
}.bind(this)
});
return {data: []};
},
render: function() {
return (
<div class="commentBox">
<div className="commentBox">
<h1>Comments</h1>
<CommentList data={this.state.data} />
<CommentForm />
@@ -399,16 +409,15 @@ var CommentBox = React.createClass({
});
```
The key is the call to `this.setState()`. We replace the old array of comments with the new one from the server and the UI automatically updates itself. Because of this reactivity, it is trivial to add live updates. We will use simple polling here but you could easily use WebSockets or other technologies.
Here, `componentWillMount` is a method called automatically by React before a component is rendered. The key to dynamic updates is the call to `this.setState()`. We replace the old array of comments with the new one from the server and the UI automatically updates itself. Because of this reactivity, it is only a minor change to add live updates. We will use simple polling here but you could easily use WebSockets or other technologies.
```javascript{3,17-21,35}
```javascript{3,16-17,31}
// tutorial14.js
var CommentBox = React.createClass({
loadCommentsFromServer: function() {
$.ajax({
url: this.props.url,
dataType: 'json',
mimeType: 'textPlain',
success: function(data) {
this.setState({data: data});
}.bind(this)
@@ -419,14 +428,11 @@ var CommentBox = React.createClass({
},
componentWillMount: function() {
this.loadCommentsFromServer();
setInterval(
this.loadCommentsFromServer.bind(this),
this.props.pollInterval
);
setInterval(this.loadCommentsFromServer, this.props.pollInterval);
},
render: function() {
return (
<div class="commentBox">
<div className="commentBox">
<h1>Comments</h1>
<CommentList data={this.state.data} />
<CommentForm />
@@ -436,13 +442,13 @@ var CommentBox = React.createClass({
});
React.renderComponent(
<CommentBox url="comments.json" pollInterval={5000} />,
<CommentBox url="comments.json" pollInterval={2000} />,
document.getElementById('content')
);
```
All we have done here is move the AJAX call to a separate method and call it when the component is first loaded and every 5 seconds after that. Try running this in your browser and changing the `comments.json` file; within 5 seconds, the changes will show!
All we have done here is move the AJAX call to a separate method and call it when the component is first loaded and every 2 seconds after that. Try running this in your browser and changing the `comments.json` file; within 2 seconds, the changes will show!
### Adding new comments
@@ -453,10 +459,10 @@ Now it's time to build the form. Our `CommentForm` component should ask the user
var CommentForm = React.createClass({
render: function() {
return (
<form class="commentForm">
<form className="commentForm">
<input type="text" placeholder="Your name" />
<input type="text" placeholder="Say something..." />
<input type="submit" />
<input type="submit" value="Post" />
</form>
);
}
@@ -465,7 +471,7 @@ var CommentForm = React.createClass({
Let's make the form interactive. When the user submits the form, we should clear it, submit a request to the server, and refresh the list of comments. To start, let's listen for the form's submit event and clear it.
```javascript{3-13,16,21}
```javascript{3-13,16-17,21}
// tutorial16.js
var CommentForm = React.createClass({
handleSubmit: function() {
@@ -481,14 +487,14 @@ var CommentForm = React.createClass({
},
render: function() {
return (
<form class="commentForm" onSubmit={this.handleSubmit}>
<form className="commentForm" onSubmit={this.handleSubmit}>
<input type="text" placeholder="Your name" ref="author" />
<input
type="text"
placeholder="Say something..."
ref="text"
/>
<input type="submit" />
<input type="submit" value="Post" />
</form>
);
}
@@ -511,14 +517,13 @@ When a user submits a comment, we will need to refresh the list of comments to i
We need to pass data from the child component to its parent. We do this by passing a `callback` in props from parent to child:
```javascript{13-15,32}
```javascript{12-14,28}
// tutorial17.js
var CommentBox = React.createClass({
loadCommentsFromServer: function() {
$.ajax({
url: this.props.url,
dataType: 'json',
mimeType: 'textPlain',
success: function(data) {
this.setState({data: data});
}.bind(this)
@@ -532,14 +537,11 @@ var CommentBox = React.createClass({
},
componentWillMount: function() {
this.loadCommentsFromServer();
setInterval(
this.loadCommentsFromServer.bind(this),
this.props.pollInterval
);
setInterval(this.loadCommentsFromServer, this.props.pollInterval);
},
render: function() {
return (
<div class="commentBox">
<div className="commentBox">
<h1>Comments</h1>
<CommentList data={this.state.data} />
<CommentForm
@@ -566,14 +568,14 @@ var CommentForm = React.createClass({
},
render: function() {
return (
<form class="commentForm" onSubmit={this.handleSubmit}>
<form className="commentForm" onSubmit={this.handleSubmit}>
<input type="text" placeholder="Your name" ref="author" />
<input
type="text"
placeholder="Say something..."
ref="text"
/>
<input type="submit" />
<input type="submit" value="Post" />
</form>
);
}
@@ -582,14 +584,13 @@ var CommentForm = React.createClass({
Now that the callbacks are in place, all we have to do is submit to the server and refresh the list:
```javascript{14-22}
```javascript{13-21}
// tutorial19.js
var CommentBox = React.createClass({
loadCommentsFromServer: function() {
$.ajax({
url: this.props.url,
dataType: 'json',
mimeType: 'textPlain',
success: function(data) {
this.setState({data: data});
}.bind(this)
@@ -598,9 +599,9 @@ var CommentBox = React.createClass({
handleCommentSubmit: function(comment) {
$.ajax({
url: this.props.url,
data: comment,
dataType: 'json',
mimeType: 'textPlain',
type: 'POST',
data: comment,
success: function(data) {
this.setState({data: data});
}.bind(this)
@@ -611,14 +612,11 @@ var CommentBox = React.createClass({
},
componentWillMount: function() {
this.loadCommentsFromServer();
setInterval(
this.loadCommentsFromServer.bind(this),
this.props.pollInterval
);
setInterval(this.loadCommentsFromServer, this.props.pollInterval);
},
render: function() {
return (
<div class="commentBox">
<div className="commentBox">
<h1>Comments</h1>
<CommentList data={this.state.data} />
<CommentForm
@@ -634,14 +632,13 @@ var CommentBox = React.createClass({
Our application is now feature complete but it feels slow to have to wait for the request to complete before your comment appears in the list. We can optimistically add this comment to the list to make the app feel faster.
```javascript{14-16}
```javascript{13-15}
// tutorial20.js
var CommentBox = React.createClass({
loadCommentsFromServer: function() {
$.ajax({
url: this.props.url,
dataType: 'json',
mimeType: 'textPlain',
success: function(data) {
this.setState({data: data});
}.bind(this)
@@ -649,13 +646,13 @@ var CommentBox = React.createClass({
},
handleCommentSubmit: function(comment) {
var comments = this.state.data;
comments.push(comment);
this.setState({data: comments});
var newComments = comments.concat([comment]);
this.setState({data: newComments});
$.ajax({
url: this.props.url,
data: comment,
dataType: 'json',
mimeType: 'textPlain',
type: 'POST',
data: comment,
success: function(data) {
this.setState({data: data});
}.bind(this)
@@ -666,14 +663,11 @@ var CommentBox = React.createClass({
},
componentWillMount: function() {
this.loadCommentsFromServer();
setInterval(
this.loadCommentsFromServer.bind(this),
this.props.pollInterval
);
setInterval(this.loadCommentsFromServer, this.props.pollInterval);
},
render: function() {
return (
<div class="commentBox">
<div className="commentBox">
<h1>Comments</h1>
<CommentList data={this.state.data} />
<CommentForm
@@ -687,4 +681,4 @@ var CommentBox = React.createClass({
### Congrats!
You have just built a comment box in a few simple steps. Learn more about [why to use React](why-react.html), or dive into the [API reference](top-level-api.html) and start hacking! Good luck!
You have just built a comment box in a few simple steps. Learn more about [why to use React](/react/docs/why-react.html), or dive into the [API reference](/react/docs/top-level-api.html) and start hacking! Good luck!

68
docs/docs/videos.md Normal file
View File

@@ -0,0 +1,68 @@
---
id: videos
title: Videos
layout: docs
permalink: videos.html
prev: thinking-in-react.html
next: complementary-tools.html
---
### Rethinking best practices - JSConf.eu
<iframe width="650" height="315" src="//www.youtube.com/embed/x7cQ3mrcKaY" frameborder="0" allowfullscreen></iframe>
"At Facebook and Instagram, were trying to push the limits of whats possible on the web with React. My talk will start with a brief introduction to the framework, and then dive into three controversial topics: Throwing out the notion of templates and building views with JavaScript, “re-rendering” your entire application when your data changes, and a lightweight implementation of the DOM and events." -- [Pete Hunt](http://www.petehunt.net/)
### JavaScript Jabber
[Pete Hunt](http://www.petehunt.net/) and [Jordan Walke](https://github.com/jordwalke) talked about React in JavaScript Jabber 73.
<figure>[![](/react/img/docs/javascript-jabber.png)](http://javascriptjabber.com/073-jsj-react-with-pete-hunt-and-jordan-walke/#content)</figure>
<table width="100%"><tr><td>
01:34 Pete Hunt Introduction<br />
02:45 Jordan Walke Introduction<br />
04:15 React<br />
06:38 60 Frames Per Second<br />
09:34 Data Binding<br />
12:31 Performance<br />
17:39 Diffing Algorithm<br />
19:36 DOM Manipulation
</td><td>
23:06 Supporting node.js<br />
24:03 rendr<br />
26:02 JSX<br />
30:31 requestAnimationFrame<br />
34:15 React and Applications<br />
38:12 React Users Khan Academy<br />
39:53 Making it work
</td></tr></table>
[Read the full transcript](http://javascriptjabber.com/073-jsj-react-with-pete-hunt-and-jordan-walke/)
### Introduction to React.js - Facebook Seattle
<iframe width="650" height="315" src="//www.youtube.com/embed/XxVg_s8xAms" frameborder="0" allowfullscreen></iframe>
By [Tom Occhino](http://tomocchino.com/) and [Jordan Walke](https://github.com/jordwalke)
### Developing User Interfaces With React - Super VanJS
<iframe width="650" height="315" src="//www.youtube.com/embed/1OeXsL5mr4g" frameborder="0" allowfullscreen></iframe>
By [Steven Luscher](https://github.com/steveluscher)
### Introduction to React - LAWebSpeed meetup
<iframe width="650" height="315" src="//www.youtube.com/embed/SMMRJif5QW0" frameborder="0" allowfullscreen></iframe>
by [Stoyan Stefanov](http://www.phpied.com/)
### "fun + React + ClojureScript" - Small Talk KyivJS Meetup
<iframe width="650" height="315" src="//www.youtube.com/embed/R2CGKiNnPFo" frameborder="0" allowfullscreen></iframe>
**In Russian** by [Alexander Solovyov](http://solovyov.net/)
### "Functional DOM programming" - Meteor DevShop 11
<iframe width="650" height="315" src="//www.youtube.com/embed/qqVbr_LaCIo" frameborder="0" allowfullscreen></iframe>

View File

@@ -4,7 +4,7 @@ title: Downloads
layout: single
---
Download the starter kit to get everything you need to
[get started with React](/react/docs/getting-started.html).
[get started with React](/react/docs/getting-started.html). The starter kit includes React, the in-browser JSX transformer, and some simple example apps.
<div class="buttons-unit downloads">
<a href="/react/downloads/react-{{site.react_version}}.zip" class="button">
@@ -12,40 +12,72 @@ Download the starter kit to get everything you need to
</a>
</div>
## Development vs. Production Builds
We provide two versions of React: an uncompressed version for development and a minified version for production. The development version includes extra warnings about common mistakes, whereas the production version includes extra performance optimizations and strips all error messages.
If you're just starting out, make sure to use the development version.
## Individual Downloads
#### <a href="http://fb.me/react-{{site.react_version}}.min.js">React Core {{site.react_version}} (production)</a>
The compressed, production version of React core
```html
<script src="http://fb.me/react-{{site.react_version}}.min.js"></script>
```
#### <a href="http://fb.me/react-{{site.react_version}}.js">React Core {{site.react_version}} (development)</a>
#### <a href="http://fb.me/react-{{site.react_version}}.js">React {{site.react_version}} (development)</a>
The uncompressed, development version of React core with inline documentation.
```html
<script src="http://fb.me/react-{{site.react_version}}.js"></script>
```
#### <a href="http://fb.me/JSXTransformer-{{site.react_version}}.js">JSX Transform</a>
#### <a href="http://fb.me/react-{{site.react_version}}.min.js">React {{site.react_version}} (production)</a>
The compressed, production version of React core.
```html
<script src="http://fb.me/react-{{site.react_version}}.min.js"></script>
```
#### <a href="http://fb.me/react-with-addons-{{site.react_version}}.js">React with Add-Ons {{site.react_version}} (development)</a>
The uncompressed, development version of React with [add-ons](/react/docs/addons.html).
```html
<script src="http://fb.me/react-with-addons-{{site.react_version}}.js"></script>
```
#### <a href="http://fb.me/react-with-addons-{{site.react_version}}.min.js">React with Add-Ons {{site.react_version}} (production)</a>
The compressed, production version of React with [add-ons](/react/docs/addons.html).
```html
<script src="http://fb.me/react-with-addons-{{site.react_version}}.min.js"></script>
```
#### <a href="http://fb.me/JSXTransformer-{{site.react_version}}.js">JSX Transformer</a>
The JSX transformer used to support [XML syntax](/react/docs/jsx-in-depth.html) in JavaScript.
```html
<script src="http://fb.me/JSXTransformer-{{site.react_version}}.js"></script>
```
All scripts are also available via [CDNJS](http://cdnjs.com/#react).
All scripts are also available via [CDNJS](http://cdnjs.com/libraries/react/).
## npm
To install the JSX transformer on your computer, run:
```sh
$ npm install -g react-tools
```
For more info about the `jsx` binary, see the [Getting Started](/react/docs/getting-started.html#offline-transform) guide.
If you're using an npm-compatible packaging system like browserify or webpack, you can use the `react` package. After installing it using `npm install react` or adding `react` to `package.json`, you can use React:
```js
var React = require('react');
React.renderComponent(...);
```
If you'd like to use any [add-ons](/react/docs/addons.html), use `var React = require('react/addons');` instead.
## Bower
```sh
$ bower install --save react
```
## NPM
```sh
$ npm install -g react-tools
```

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

11
docs/html-jsx.md Normal file
View File

@@ -0,0 +1,11 @@
---
layout: default
title: HTML to JSX
id: html-jsx
---
<div class="jsxCompiler">
<h1>HTML to JSX Compiler</h1>
<div id="jsxCompiler"></div>
<script src="js/html-jsx-lib.js"></script>
<script src="js/html-jsx.js"></script>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Some files were not shown because too many files have changed in this diff Show More