diff --git a/404.html b/404.html index 5c25dd0dd3..e25947e5a9 100644 --- a/404.html +++ b/404.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/acknowledgements.html b/acknowledgements.html index d5a300f8e0..fb17b10ff6 100644 --- a/acknowledgements.html +++ b/acknowledgements.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -206,8 +207,6 @@
  • Beau Smith
  • -
  • Ben Alpert
  • -
  • Ben Anderson
  • Ben Brooks
  • @@ -1258,6 +1257,8 @@
  • Sophia Westwood
  • +
  • Sophie Alpert
  • +
  • Sota Ohara
  • Spencer Handley
  • diff --git a/blog/2013/06/02/jsfiddle-integration.html b/blog/2013/06/02/jsfiddle-integration.html index b1ae9b06bc..3bbc6bba34 100644 --- a/blog/2013/06/02/jsfiddle-integration.html +++ b/blog/2013/06/02/jsfiddle-integration.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -114,6 +115,8 @@

    Recent posts

    diff --git a/blog/2013/06/05/why-react.html b/blog/2013/06/05/why-react.html index eeb1e8866c..fc3f9b1c0b 100644 --- a/blog/2013/06/05/why-react.html +++ b/blog/2013/06/05/why-react.html @@ -38,6 +38,7 @@ and why would you want to use it? + @@ -65,7 +66,7 @@ and why would you want to use it? @@ -199,6 +200,8 @@ but if you are interested in the nuts and bolts

    Recent posts

    diff --git a/blog/2013/06/12/community-roundup.html b/blog/2013/06/12/community-roundup.html index 7a46b64384..bf7f49390c 100644 --- a/blog/2013/06/12/community-roundup.html +++ b/blog/2013/06/12/community-roundup.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -100,15 +101,15 @@

    Khan Academy Question Editor

    -

    It looks like Ben Alpert is the first person outside of Facebook and Instagram to push React code to production. We are very grateful for his contributions in form of pull requests, bug reports and presence on IRC (#reactjs on Freenode). Ben wrote about his experience using React:

    +

    It looks like Sophie Alpert is the first person outside of Facebook and Instagram to push React code to production. We are very grateful for her contributions in form of pull requests, bug reports and presence on IRC (#reactjs on Freenode). Sophie wrote about her experience using React:

    I just rewrote a 2000-line project in React and have now made a handful of pull requests to React. Everything about React I've seen so far seems really well thought-out and I'm proud to be the first non-FB/IG production user of React.

    The project that I rewrote in React (and am continuing to improve) is the Khan Academy question editor which content creators can use to enter questions and hints that will be presented to students: -

    +

    -

    Read the full post...

    +

    Read the full post...

    Pimp my Backbone.View (by replacing it with React)

    @@ -159,6 +160,8 @@

    Recent posts

    diff --git a/blog/2013/06/19/community-roundup-2.html b/blog/2013/06/19/community-roundup-2.html index 16d40a67ea..87481dadf7 100644 --- a/blog/2013/06/19/community-roundup-2.html +++ b/blog/2013/06/19/community-roundup-2.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -186,6 +187,8 @@

    Recent posts

    diff --git a/blog/2013/06/21/react-v0-3-3.html b/blog/2013/06/21/react-v0-3-3.html index 1a591d4abc..2230e540a0 100644 --- a/blog/2013/06/21/react-v0-3-3.html +++ b/blog/2013/06/21/react-v0-3-3.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -130,6 +131,8 @@

    Recent posts

    diff --git a/blog/2013/06/27/community-roundup-3.html b/blog/2013/06/27/community-roundup-3.html index 8d460cc95b..3a11968738 100644 --- a/blog/2013/06/27/community-roundup-3.html +++ b/blog/2013/06/27/community-roundup-3.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -195,6 +196,8 @@

    Recent posts

    diff --git a/blog/2013/07/02/react-v0-4-autobind-by-default.html b/blog/2013/07/02/react-v0-4-autobind-by-default.html index 0f7ad58101..1fe14dbcee 100644 --- a/blog/2013/07/02/react-v0-4-autobind-by-default.html +++ b/blog/2013/07/02/react-v0-4-autobind-by-default.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -144,6 +145,8 @@

    Recent posts

    diff --git a/blog/2013/07/03/community-roundup-4.html b/blog/2013/07/03/community-roundup-4.html index da04557256..0153289ddb 100644 --- a/blog/2013/07/03/community-roundup-4.html +++ b/blog/2013/07/03/community-roundup-4.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -100,7 +101,7 @@

    Khan Academy

    -

    Ben Kamens explains how Ben Alpert and Joel Burget are promoting React inside of Khan Academy. They now have three projects in the works using React.

    +

    Ben Kamens explains how Sophie Alpert and Joel Burget are promoting React inside of Khan Academy. They now have three projects in the works using React.

    Recently two Khan Academy devs dropped into our team chat and said they were gonna use React to write a new feature. They even hinted that we may want to adopt it product-wide.

    @@ -177,6 +178,8 @@

    Recent posts

    diff --git a/blog/2013/07/11/react-v0-4-prop-validation-and-default-values.html b/blog/2013/07/11/react-v0-4-prop-validation-and-default-values.html index c78525204c..cfffc64b21 100644 --- a/blog/2013/07/11/react-v0-4-prop-validation-and-default-values.html +++ b/blog/2013/07/11/react-v0-4-prop-validation-and-default-values.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -155,6 +156,8 @@

    Recent posts

    diff --git a/blog/2013/07/17/react-v0-4-0.html b/blog/2013/07/17/react-v0-4-0.html index 3b02583d0b..8df89b78e7 100644 --- a/blog/2013/07/17/react-v0-4-0.html +++ b/blog/2013/07/17/react-v0-4-0.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -147,6 +148,8 @@ If you were using React without JSX previously, your code should still work.Recent posts diff --git a/blog/2013/07/23/community-roundup-5.html b/blog/2013/07/23/community-roundup-5.html index 3468b376aa..e3ea37e5a4 100644 --- a/blog/2013/07/23/community-roundup-5.html +++ b/blog/2013/07/23/community-roundup-5.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -100,14 +101,14 @@

    Cross-browser onChange

    -

    Ben Alpert from Khan Academy worked on a cross-browser implementation of onChange event that landed in v0.4. He wrote a blog post explaining the various browser quirks he had to deal with.

    +

    Sophie Alpert from Khan Academy worked on a cross-browser implementation of onChange event that landed in v0.4. She wrote a blog post explaining the various browser quirks she had to deal with.

    First off, what is the input event? If you have an <input> element and want to receive events whenever the value changes, the most obvious thing to do is to listen to the change event. Unfortunately, change fires only after the text field is defocused, rather than on each keystroke. The next obvious choice is the keyup event, which is triggered whenever a key is released. Unfortunately, keyup doesn't catch input that doesn't involve the keyboard (e.g., pasting from the clipboard using the mouse) and only fires once if a key is held down, rather than once per inserted character.

    Both keydown and keypress do fire repeatedly when a key is held down, but both fire immediately before the value changes, so to read the new value you have to defer the handler to the next event loop using setTimeout(fn, 0) or similar, which slows down your app. Of course, like keyup, neither keydown nor keypress fires for non-keyboard input events, and all three can fire in cases where the value doesn't change at all (such as when pressing the arrow keys).

    -

    Read the full post...

    +

    Read the full post...

    React Samples

    @@ -210,6 +211,8 @@

    Recent posts

    diff --git a/blog/2013/07/26/react-v0-4-1.html b/blog/2013/07/26/react-v0-4-1.html index 596c4056a7..a7d0a97d66 100644 --- a/blog/2013/07/26/react-v0-4-1.html +++ b/blog/2013/07/26/react-v0-4-1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -129,6 +130,8 @@

    Recent posts

    diff --git a/blog/2013/07/30/use-react-and-jsx-in-ruby-on-rails.html b/blog/2013/07/30/use-react-and-jsx-in-ruby-on-rails.html index 7c0cb476f9..71bda3315e 100644 --- a/blog/2013/07/30/use-react-and-jsx-in-ruby-on-rails.html +++ b/blog/2013/07/30/use-react-and-jsx-in-ruby-on-rails.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -144,6 +145,8 @@

    Recent posts

    diff --git a/blog/2013/08/05/community-roundup-6.html b/blog/2013/08/05/community-roundup-6.html index 1e305ce181..4e8465f981 100644 --- a/blog/2013/08/05/community-roundup-6.html +++ b/blog/2013/08/05/community-roundup-6.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -183,6 +184,8 @@

    Recent posts

    diff --git a/blog/2013/08/19/use-react-and-jsx-in-python-applications.html b/blog/2013/08/19/use-react-and-jsx-in-python-applications.html index 231238d65c..65bbaa6f33 100644 --- a/blog/2013/08/19/use-react-and-jsx-in-python-applications.html +++ b/blog/2013/08/19/use-react-and-jsx-in-python-applications.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -148,6 +149,8 @@

    Recent posts

    diff --git a/blog/2013/08/26/community-roundup-7.html b/blog/2013/08/26/community-roundup-7.html index 35b66a4973..256b94ceb6 100644 --- a/blog/2013/08/26/community-roundup-7.html +++ b/blog/2013/08/26/community-roundup-7.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -105,7 +106,7 @@
  • 76 GitHub projects using React
  • 30 contributors
  • 15 blog posts
  • -
  • 2 early adopters: Khan Academy and Propeller
  • +
  • 2 early adopters: Khan Academy and Propeller
  • Wolfenstein Rendering Engine Ported to React

    @@ -188,6 +189,8 @@

    Recent posts

    diff --git a/blog/2013/09/24/community-roundup-8.html b/blog/2013/09/24/community-roundup-8.html index 972ea848eb..107ecefad2 100644 --- a/blog/2013/09/24/community-roundup-8.html +++ b/blog/2013/09/24/community-roundup-8.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -113,7 +114,7 @@

    PETE: Exactly, exactly. In order to implement that, we communicate it as a fake DOM. What we'll do is rather than throw out the actual browser html and event handlers, we have an internal representation of what the page looks like and then we generate a brand new representation of what we want the page to look like. Then we perform this really, really fast diffing algorithm between those two page representations, DOM representations. Then React will compute the minimum set of DOM mutations it needs to make to bring the page up to date.

    -

    Then to finally get to answer your question, that set of DOM mutations then goes into a queue and we can plug in arbitrary flushing strategies for that. For example, when we originally launched React in open source, every setState would immediately trigger a flush to the DOM. That wasn't part of the contract of setState, but that was just our strategy and it worked pretty well. Then this totally awesome open source contributor Ben Alpert at Khan Academy built a new batching strategy which would basically queue up every single DOM update and state change that happened within an event tick and would execute them in bulk at the end of the event tick.

    +

    Then to finally get to answer your question, that set of DOM mutations then goes into a queue and we can plug in arbitrary flushing strategies for that. For example, when we originally launched React in open source, every setState would immediately trigger a flush to the DOM. That wasn't part of the contract of setState, but that was just our strategy and it worked pretty well. Then this totally awesome open source contributor Sophie Alpert at Khan Academy built a new batching strategy which would basically queue up every single DOM update and state change that happened within an event tick and would execute them in bulk at the end of the event tick.

    Read the full conversation ...

    @@ -148,8 +149,8 @@

    Markdown in React

    -

    Ben Alpert converted marked, a Markdown JavaScript implementation, in React: marked-react. Even without using JSX, the HTML generation is now a lot cleaner. It is also safer as forgetting a call to escape will not introduce an XSS vulnerability. -

    +

    Sophie Alpert converted marked, a Markdown JavaScript implementation, in React: marked-react. Even without using JSX, the HTML generation is now a lot cleaner. It is also safer as forgetting a call to escape will not introduce an XSS vulnerability. +

    Unite from BugBusters

    @@ -174,6 +175,8 @@

    Recent posts

    diff --git a/blog/2013/10/03/community-roundup-9.html b/blog/2013/10/03/community-roundup-9.html index b458da992f..e940eaca2b 100644 --- a/blog/2013/10/03/community-roundup-9.html +++ b/blog/2013/10/03/community-roundup-9.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -198,6 +199,8 @@

    Recent posts

    diff --git a/blog/2013/10/16/react-v0.5.0.html b/blog/2013/10/16/react-v0.5.0.html index d76736711c..d9ad3e2603 100644 --- a/blog/2013/10/16/react-v0.5.0.html +++ b/blog/2013/10/16/react-v0.5.0.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -160,6 +161,8 @@

    Recent posts

    diff --git a/blog/2013/10/29/react-v0-5-1.html b/blog/2013/10/29/react-v0-5-1.html index 52dc35b3e2..60335bde7c 100644 --- a/blog/2013/10/29/react-v0-5-1.html +++ b/blog/2013/10/29/react-v0-5-1.html @@ -12,7 +12,7 @@ - @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -96,7 +97,7 @@
    -

    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, Andrey Popp, and Laurence Rowe for their contributions!

    +

    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 Sophie Alpert, Andrey Popp, and Laurence Rowe for their contributions!

    Changelog

    @@ -127,6 +128,8 @@

    Recent posts

    diff --git a/blog/2013/11/06/community-roundup-10.html b/blog/2013/11/06/community-roundup-10.html index 41b4140472..dca2baa0d1 100644 --- a/blog/2013/11/06/community-roundup-10.html +++ b/blog/2013/11/06/community-roundup-10.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -233,6 +234,8 @@

    Recent posts

    diff --git a/blog/2013/11/18/community-roundup-11.html b/blog/2013/11/18/community-roundup-11.html index 67dcc8086f..84631ac0de 100644 --- a/blog/2013/11/18/community-roundup-11.html +++ b/blog/2013/11/18/community-roundup-11.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -196,6 +197,8 @@ Is this some sort of template language? Specifically no. This might have been th

    Recent posts

    diff --git a/blog/2013/12/18/react-v0.5.2-v0.4.2.html b/blog/2013/12/18/react-v0.5.2-v0.4.2.html index 0bd02b216b..3cccc7a3df 100644 --- a/blog/2013/12/18/react-v0.5.2-v0.4.2.html +++ b/blog/2013/12/18/react-v0.5.2-v0.4.2.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -120,6 +121,8 @@

    Recent posts

    diff --git a/blog/2013/12/19/react-v0.8.0.html b/blog/2013/12/19/react-v0.8.0.html index 166d84f187..b59abb1c65 100644 --- a/blog/2013/12/19/react-v0.8.0.html +++ b/blog/2013/12/19/react-v0.8.0.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -160,6 +161,8 @@

    Recent posts

    diff --git a/blog/2013/12/23/community-roundup-12.html b/blog/2013/12/23/community-roundup-12.html index f31c5ce60d..8b5c4b30fc 100644 --- a/blog/2013/12/23/community-roundup-12.html +++ b/blog/2013/12/23/community-roundup-12.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -198,6 +199,8 @@ componentDidUpdate: function() {

    Recent posts

    diff --git a/blog/2013/12/30/community-roundup-13.html b/blog/2013/12/30/community-roundup-13.html index e50c06d189..1bc4088838 100644 --- a/blog/2013/12/30/community-roundup-13.html +++ b/blog/2013/12/30/community-roundup-13.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -213,6 +214,8 @@

    Recent posts

    diff --git a/blog/2014/01/02/react-chrome-developer-tools.html b/blog/2014/01/02/react-chrome-developer-tools.html index 80a7c956f1..a6129e16f6 100644 --- a/blog/2014/01/02/react-chrome-developer-tools.html +++ b/blog/2014/01/02/react-chrome-developer-tools.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -121,6 +122,8 @@

    Recent posts

    diff --git a/blog/2014/01/06/community-roundup-14.html b/blog/2014/01/06/community-roundup-14.html index adcc32c0a7..052ecd8bef 100644 --- a/blog/2014/01/06/community-roundup-14.html +++ b/blog/2014/01/06/community-roundup-14.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -190,6 +191,8 @@ rails s

    Recent posts

    diff --git a/blog/2014/02/05/community-roundup-15.html b/blog/2014/02/05/community-roundup-15.html index 1f56060cac..7441bdfec8 100644 --- a/blog/2014/02/05/community-roundup-15.html +++ b/blog/2014/02/05/community-roundup-15.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -234,6 +235,8 @@

    Recent posts

    diff --git a/blog/2014/02/15/community-roundup-16.html b/blog/2014/02/15/community-roundup-16.html index 4348f4f554..c1a2d1fc06 100644 --- a/blog/2014/02/15/community-roundup-16.html +++ b/blog/2014/02/15/community-roundup-16.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -187,6 +188,8 @@

    Recent posts

    diff --git a/blog/2014/02/16/react-v0.9-rc1.html b/blog/2014/02/16/react-v0.9-rc1.html index f4de40bde3..e2f0e3d937 100644 --- a/blog/2014/02/16/react-v0.9-rc1.html +++ b/blog/2014/02/16/react-v0.9-rc1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -87,7 +88,7 @@ by - Ben Alpert + Sophie Alpert @@ -242,6 +243,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -260,8 +263,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/02/20/react-v0.9.html b/blog/2014/02/20/react-v0.9.html index 1dc6d4a248..64362125f8 100644 --- a/blog/2014/02/20/react-v0.9.html +++ b/blog/2014/02/20/react-v0.9.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -87,7 +88,7 @@ by - Ben Alpert + Sophie Alpert @@ -254,6 +255,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -272,8 +275,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/02/24/community-roundup-17.html b/blog/2014/02/24/community-roundup-17.html index 7c91d91547..808b843e09 100644 --- a/blog/2014/02/24/community-roundup-17.html +++ b/blog/2014/02/24/community-roundup-17.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -194,6 +195,8 @@

    Recent posts

    diff --git a/blog/2014/03/14/community-roundup-18.html b/blog/2014/03/14/community-roundup-18.html index 51a75ada69..e6b7c375fa 100644 --- a/blog/2014/03/14/community-roundup-18.html +++ b/blog/2014/03/14/community-roundup-18.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -213,6 +214,8 @@ Thomas Boyt (@thomasaboyt) wrote <

    Recent posts

    diff --git a/blog/2014/03/19/react-v0.10-rc1.html b/blog/2014/03/19/react-v0.10-rc1.html index ef246a7a8d..46a3f389b1 100644 --- a/blog/2014/03/19/react-v0.10-rc1.html +++ b/blog/2014/03/19/react-v0.10-rc1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -188,6 +189,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -206,8 +209,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/03/21/react-v0.10.html b/blog/2014/03/21/react-v0.10.html index f2c339d63c..f007c8feed 100644 --- a/blog/2014/03/21/react-v0.10.html +++ b/blog/2014/03/21/react-v0.10.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -188,6 +189,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -206,8 +209,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/03/28/the-road-to-1.0.html b/blog/2014/03/28/the-road-to-1.0.html index c1ff49e84e..fc068128b3 100644 --- a/blog/2014/03/28/the-road-to-1.0.html +++ b/blog/2014/03/28/the-road-to-1.0.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -153,6 +154,8 @@

    Recent posts

    diff --git a/blog/2014/04/04/reactnet.html b/blog/2014/04/04/reactnet.html index 3049fff28b..ca28c7880d 100644 --- a/blog/2014/04/04/reactnet.html +++ b/blog/2014/04/04/reactnet.html @@ -40,6 +40,7 @@ It has several purposes: + @@ -67,7 +68,7 @@ It has several purposes: @@ -146,6 +147,8 @@ report bugs on GitHub.

    Recent posts

    diff --git a/blog/2014/05/06/flux.html b/blog/2014/05/06/flux.html index 14d5c699e0..8c809c882e 100644 --- a/blog/2014/05/06/flux.html +++ b/blog/2014/05/06/flux.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -125,6 +126,8 @@

    Recent posts

    diff --git a/blog/2014/05/29/one-year-of-open-source-react.html b/blog/2014/05/29/one-year-of-open-source-react.html index 22cd54ced3..3db2717738 100644 --- a/blog/2014/05/29/one-year-of-open-source-react.html +++ b/blog/2014/05/29/one-year-of-open-source-react.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -118,6 +119,8 @@

    Recent posts

    diff --git a/blog/2014/06/27/community-roundup-19.html b/blog/2014/06/27/community-roundup-19.html index 8a855e0ac5..05d11f1a94 100644 --- a/blog/2014/06/27/community-roundup-19.html +++ b/blog/2014/06/27/community-roundup-19.html @@ -39,6 +39,7 @@ Ever wanted to find developers who also share the same interest in React than yo + @@ -66,7 +67,7 @@ Ever wanted to find developers who also share the same interest in React than yo @@ -170,6 +171,8 @@ Ever wanted to find developers who also share the same interest in React than yo

    Recent posts

    diff --git a/blog/2014/07/13/react-v0.11-rc1.html b/blog/2014/07/13/react-v0.11-rc1.html index 4e3d4f6d75..e84dd2fd22 100644 --- a/blog/2014/07/13/react-v0.11-rc1.html +++ b/blog/2014/07/13/react-v0.11-rc1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -261,6 +262,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -279,8 +282,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/07/17/react-v0.11.html b/blog/2014/07/17/react-v0.11.html index 6e5e249a6f..3e8be4936e 100644 --- a/blog/2014/07/17/react-v0.11.html +++ b/blog/2014/07/17/react-v0.11.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -280,6 +281,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -298,8 +301,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/07/25/react-v0.11.1.html b/blog/2014/07/25/react-v0.11.1.html index 55b5eaf15e..ca07bcd203 100644 --- a/blog/2014/07/25/react-v0.11.1.html +++ b/blog/2014/07/25/react-v0.11.1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -155,6 +156,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -173,8 +176,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/07/28/community-roundup-20.html b/blog/2014/07/28/community-roundup-20.html index 2a0c3e72bf..f7e85c80dd 100644 --- a/blog/2014/07/28/community-roundup-20.html +++ b/blog/2014/07/28/community-roundup-20.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -207,6 +208,8 @@

    Recent posts

    diff --git a/blog/2014/07/30/flux-actions-and-the-dispatcher.html b/blog/2014/07/30/flux-actions-and-the-dispatcher.html index 3bd8812280..77e94a8130 100644 --- a/blog/2014/07/30/flux-actions-and-the-dispatcher.html +++ b/blog/2014/07/30/flux-actions-and-the-dispatcher.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -142,6 +143,8 @@

    Recent posts

    diff --git a/blog/2014/08/03/community-roundup-21.html b/blog/2014/08/03/community-roundup-21.html index 4d5167628d..70a8bee52e 100644 --- a/blog/2014/08/03/community-roundup-21.html +++ b/blog/2014/08/03/community-roundup-21.html @@ -39,6 +39,7 @@ Ryan Florence and Michael Jackson ported Ember's router to React in a projec + @@ -66,7 +67,7 @@ Ryan Florence and Michael Jackson ported Ember's router to React in a projec @@ -206,6 +207,8 @@ This is not the intended way to use React but can be useful as last resort if yo

    Recent posts

    diff --git a/blog/2014/09/03/introducing-the-jsx-specification.html b/blog/2014/09/03/introducing-the-jsx-specification.html index 6416324dfe..7eb7ee7f9a 100644 --- a/blog/2014/09/03/introducing-the-jsx-specification.html +++ b/blog/2014/09/03/introducing-the-jsx-specification.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -118,6 +119,8 @@

    Recent posts

    diff --git a/blog/2014/09/12/community-round-up-22.html b/blog/2014/09/12/community-round-up-22.html index 66a0710f28..925e636e01 100644 --- a/blog/2014/09/12/community-round-up-22.html +++ b/blog/2014/09/12/community-round-up-22.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -208,6 +209,8 @@

    Recent posts

    diff --git a/blog/2014/09/16/react-v0.11.2.html b/blog/2014/09/16/react-v0.11.2.html index 348e573d55..99a693e1d8 100644 --- a/blog/2014/09/16/react-v0.11.2.html +++ b/blog/2014/09/16/react-v0.11.2.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -164,6 +165,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -182,8 +185,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/09/24/testing-flux-applications.html b/blog/2014/09/24/testing-flux-applications.html index 75c030f058..fa99a91015 100644 --- a/blog/2014/09/24/testing-flux-applications.html +++ b/blog/2014/09/24/testing-flux-applications.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -386,6 +387,8 @@

    Recent posts

    diff --git a/blog/2014/10/14/introducing-react-elements.html b/blog/2014/10/14/introducing-react-elements.html index 8f5dcf1d98..6f91fbc798 100644 --- a/blog/2014/10/14/introducing-react-elements.html +++ b/blog/2014/10/14/introducing-react-elements.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -274,6 +275,8 @@

    Recent posts

    diff --git a/blog/2014/10/16/react-v0.12-rc1.html b/blog/2014/10/16/react-v0.12-rc1.html index 01182acb8a..9850146f5d 100644 --- a/blog/2014/10/16/react-v0.12-rc1.html +++ b/blog/2014/10/16/react-v0.12-rc1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -227,6 +228,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -245,8 +248,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/10/17/community-roundup-23.html b/blog/2014/10/17/community-roundup-23.html index fc42320a70..1015acf272 100644 --- a/blog/2014/10/17/community-roundup-23.html +++ b/blog/2014/10/17/community-roundup-23.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -252,6 +253,8 @@

    Recent posts

    diff --git a/blog/2014/10/27/react-js-conf.html b/blog/2014/10/27/react-js-conf.html index ee0fef729b..cc47ebad2e 100644 --- a/blog/2014/10/27/react-js-conf.html +++ b/blog/2014/10/27/react-js-conf.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -118,6 +119,8 @@

    Recent posts

    diff --git a/blog/2014/10/28/react-v0.12.html b/blog/2014/10/28/react-v0.12.html index f5b152cd83..6c87193a48 100644 --- a/blog/2014/10/28/react-v0.12.html +++ b/blog/2014/10/28/react-v0.12.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -257,6 +258,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -275,8 +278,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/11/24/react-js-conf-updates.html b/blog/2014/11/24/react-js-conf-updates.html index 2a8a625926..10910eca0b 100644 --- a/blog/2014/11/24/react-js-conf-updates.html +++ b/blog/2014/11/24/react-js-conf-updates.html @@ -39,6 +39,7 @@ amazed that 600 people requested to be notified when ticket go on sale. This is + @@ -66,7 +67,7 @@ amazed that 600 people requested to be notified when ticket go on sale. This is @@ -147,6 +148,8 @@ until the next conference. All the talks will be recorded and put online shortly

    Recent posts

    diff --git a/blog/2014/11/25/community-roundup-24.html b/blog/2014/11/25/community-roundup-24.html index fcff206f97..3e80698bd0 100644 --- a/blog/2014/11/25/community-roundup-24.html +++ b/blog/2014/11/25/community-roundup-24.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -202,6 +203,8 @@

    Recent posts

    diff --git a/blog/2014/12/18/react-v0.12.2.html b/blog/2014/12/18/react-v0.12.2.html index c8fb123fe9..87996b0f58 100644 --- a/blog/2014/12/18/react-v0.12.2.html +++ b/blog/2014/12/18/react-v0.12.2.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -146,6 +147,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -164,8 +167,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2014/12/19/react-js-conf-diversity-scholarship.html b/blog/2014/12/19/react-js-conf-diversity-scholarship.html index 0313fd6c30..db6c85ffae 100644 --- a/blog/2014/12/19/react-js-conf-diversity-scholarship.html +++ b/blog/2014/12/19/react-js-conf-diversity-scholarship.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -147,6 +148,8 @@ Facebook will make determinations on scholarship recipients in its sole discreti

    Recent posts

    diff --git a/blog/2015/01/27/react-v0.13.0-beta-1.html b/blog/2015/01/27/react-v0.13.0-beta-1.html index b612d80678..c12a006f79 100644 --- a/blog/2015/01/27/react-v0.13.0-beta-1.html +++ b/blog/2015/01/27/react-v0.13.0-beta-1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -248,6 +249,8 @@

    Recent posts

    diff --git a/blog/2015/02/18/react-conf-roundup-2015.html b/blog/2015/02/18/react-conf-roundup-2015.html index 8195abb11e..b289a0888c 100644 --- a/blog/2015/02/18/react-conf-roundup-2015.html +++ b/blog/2015/02/18/react-conf-roundup-2015.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -326,7 +327,7 @@

    Core Team Q&A #

    - Tom Occhino, Ben Alpert, Lee Byron, Christopher Chedeau, Sebastian Markbåge, Jing Chen, and Dan Schafer closed the conference with a Q&A session. + Tom Occhino, Sophie Alpert, Lee Byron, Christopher Chedeau, Sebastian Markbåge, Jing Chen, and Dan Schafer closed the conference with a Q&A session.

    @@ -373,6 +374,8 @@

    Recent posts

    diff --git a/blog/2015/02/20/introducing-relay-and-graphql.html b/blog/2015/02/20/introducing-relay-and-graphql.html index ca71a696ce..55f9dede14 100644 --- a/blog/2015/02/20/introducing-relay-and-graphql.html +++ b/blog/2015/02/20/introducing-relay-and-graphql.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -168,6 +169,8 @@

    Recent posts

    diff --git a/blog/2015/02/24/react-v0.13-rc1.html b/blog/2015/02/24/react-v0.13-rc1.html index 2c628e53bb..badc9b519b 100644 --- a/blog/2015/02/24/react-v0.13-rc1.html +++ b/blog/2015/02/24/react-v0.13-rc1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -197,6 +198,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -215,8 +218,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2015/02/24/streamlining-react-elements.html b/blog/2015/02/24/streamlining-react-elements.html index 84e504d0e3..e18288bf94 100644 --- a/blog/2015/02/24/streamlining-react-elements.html +++ b/blog/2015/02/24/streamlining-react-elements.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -296,6 +297,8 @@

    Recent posts

    diff --git a/blog/2015/03/03/react-v0.13-rc2.html b/blog/2015/03/03/react-v0.13-rc2.html index 25686eac25..2adb3d4571 100644 --- a/blog/2015/03/03/react-v0.13-rc2.html +++ b/blog/2015/03/03/react-v0.13-rc2.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -159,6 +160,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -177,8 +180,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2015/03/04/community-roundup-25.html b/blog/2015/03/04/community-roundup-25.html index 01e4c8e0a4..e1c38c6a09 100644 --- a/blog/2015/03/04/community-roundup-25.html +++ b/blog/2015/03/04/community-roundup-25.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -166,6 +167,8 @@

    Recent posts

    diff --git a/blog/2015/03/10/react-v0.13.html b/blog/2015/03/10/react-v0.13.html index 2777be67d6..68a90b1ed4 100644 --- a/blog/2015/03/10/react-v0.13.html +++ b/blog/2015/03/10/react-v0.13.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -87,7 +88,7 @@ by - Ben Alpert + Sophie Alpert @@ -213,6 +214,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -231,8 +234,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2015/03/16/react-v0.13.1.html b/blog/2015/03/16/react-v0.13.1.html index 50ccce09e8..5488928f80 100644 --- a/blog/2015/03/16/react-v0.13.1.html +++ b/blog/2015/03/16/react-v0.13.1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -158,6 +159,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -176,8 +179,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2015/03/19/building-the-facebook-news-feed-with-relay.html b/blog/2015/03/19/building-the-facebook-news-feed-with-relay.html index 583afaac5a..2c1cbdfaa6 100644 --- a/blog/2015/03/19/building-the-facebook-news-feed-with-relay.html +++ b/blog/2015/03/19/building-the-facebook-news-feed-with-relay.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -307,6 +308,8 @@

    Recent posts

    diff --git a/blog/2015/03/26/introducing-react-native.html b/blog/2015/03/26/introducing-react-native.html index 99c7155e09..c7207a4e05 100644 --- a/blog/2015/03/26/introducing-react-native.html +++ b/blog/2015/03/26/introducing-react-native.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -87,7 +88,7 @@ by - Ben Alpert + Sophie Alpert @@ -122,6 +123,8 @@

    Recent posts

    diff --git a/blog/2015/03/30/community-roundup-26.html b/blog/2015/03/30/community-roundup-26.html index 011cabd12d..4e1fb5e392 100644 --- a/blog/2015/03/30/community-roundup-26.html +++ b/blog/2015/03/30/community-roundup-26.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -186,6 +187,8 @@

    Recent posts

    diff --git a/blog/2015/04/17/react-native-v0.4.html b/blog/2015/04/17/react-native-v0.4.html index 606ddef646..903146def1 100644 --- a/blog/2015/04/17/react-native-v0.4.html +++ b/blog/2015/04/17/react-native-v0.4.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -130,6 +131,8 @@

    Recent posts

    diff --git a/blog/2015/04/18/react-v0.13.2.html b/blog/2015/04/18/react-v0.13.2.html index 5c8d9610cd..1914ef3194 100644 --- a/blog/2015/04/18/react-v0.13.2.html +++ b/blog/2015/04/18/react-v0.13.2.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -167,6 +168,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -185,8 +188,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2015/05/01/graphql-introduction.html b/blog/2015/05/01/graphql-introduction.html index a7bb2966f1..398780fa16 100644 --- a/blog/2015/05/01/graphql-introduction.html +++ b/blog/2015/05/01/graphql-introduction.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -205,6 +206,8 @@

    Recent posts

    diff --git a/blog/2015/05/08/react-v0.13.3.html b/blog/2015/05/08/react-v0.13.3.html index 0c61583cda..cd87905b59 100644 --- a/blog/2015/05/08/react-v0.13.3.html +++ b/blog/2015/05/08/react-v0.13.3.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -154,6 +155,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -172,8 +175,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2015/05/22/react-native-release-process.html b/blog/2015/05/22/react-native-release-process.html index d23e8f31f1..37bd5ec307 100644 --- a/blog/2015/05/22/react-native-release-process.html +++ b/blog/2015/05/22/react-native-release-process.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -128,6 +129,8 @@

    Recent posts

    diff --git a/blog/2015/06/12/deprecating-jstransform-and-react-tools.html b/blog/2015/06/12/deprecating-jstransform-and-react-tools.html index 49629fd05f..2f53c6c809 100644 --- a/blog/2015/06/12/deprecating-jstransform-and-react-tools.html +++ b/blog/2015/06/12/deprecating-jstransform-and-react-tools.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -134,6 +135,8 @@

    Recent posts

    diff --git a/blog/2015/07/03/react-v0.14-beta-1.html b/blog/2015/07/03/react-v0.14-beta-1.html index fc60cad9dd..6e71dc8440 100644 --- a/blog/2015/07/03/react-v0.14-beta-1.html +++ b/blog/2015/07/03/react-v0.14-beta-1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -87,7 +88,7 @@ by - Ben Alpert + Sophie Alpert @@ -173,6 +174,8 @@

    Recent posts

    diff --git a/blog/2015/08/03/new-react-devtools-beta.html b/blog/2015/08/03/new-react-devtools-beta.html index c9eb693c5a..f8b057dc4c 100644 --- a/blog/2015/08/03/new-react-devtools-beta.html +++ b/blog/2015/08/03/new-react-devtools-beta.html @@ -38,6 +38,7 @@ out! + @@ -65,7 +66,7 @@ out! @@ -205,6 +206,8 @@ for more info.

    Recent posts

    diff --git a/blog/2015/08/11/relay-technical-preview.html b/blog/2015/08/11/relay-technical-preview.html index 2961143e49..4bd68bb5ae 100644 --- a/blog/2015/08/11/relay-technical-preview.html +++ b/blog/2015/08/11/relay-technical-preview.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -141,6 +142,8 @@

    Recent posts

    diff --git a/blog/2015/08/13/reacteurope-roundup.html b/blog/2015/08/13/reacteurope-roundup.html index c993f451e6..c43ea7f00d 100644 --- a/blog/2015/08/13/reacteurope-roundup.html +++ b/blog/2015/08/13/reacteurope-roundup.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -167,6 +168,8 @@

    Recent posts

    diff --git a/blog/2015/09/02/new-react-developer-tools.html b/blog/2015/09/02/new-react-developer-tools.html index a418d50ad3..13a1c12682 100644 --- a/blog/2015/09/02/new-react-developer-tools.html +++ b/blog/2015/09/02/new-react-developer-tools.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -87,7 +88,7 @@ by - Ben Alpert + Sophie Alpert @@ -132,6 +133,8 @@

    Recent posts

    diff --git a/blog/2015/09/10/react-v0.14-rc1.html b/blog/2015/09/10/react-v0.14-rc1.html index c40debf317..35590d8aa1 100644 --- a/blog/2015/09/10/react-v0.14-rc1.html +++ b/blog/2015/09/10/react-v0.14-rc1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -87,7 +88,7 @@ by - Ben Alpert + Sophie Alpert @@ -286,6 +287,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -304,8 +307,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2015/09/14/community-roundup-27.html b/blog/2015/09/14/community-roundup-27.html index 857fb67193..d3fd16de1a 100644 --- a/blog/2015/09/14/community-roundup-27.html +++ b/blog/2015/09/14/community-roundup-27.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -187,6 +188,8 @@

    Recent posts

    diff --git a/blog/2015/10/01/react-render-and-top-level-api.html b/blog/2015/10/01/react-render-and-top-level-api.html index 4e9114b52e..420cc38ab0 100644 --- a/blog/2015/10/01/react-render-and-top-level-api.html +++ b/blog/2015/10/01/react-render-and-top-level-api.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -225,6 +226,8 @@

    Recent posts

    diff --git a/blog/2015/10/07/react-v0.14.html b/blog/2015/10/07/react-v0.14.html index 3594495713..59343b6085 100644 --- a/blog/2015/10/07/react-v0.14.html +++ b/blog/2015/10/07/react-v0.14.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -87,7 +88,7 @@ by - Ben Alpert + Sophie Alpert @@ -313,6 +314,8 @@ Minified build for production: h

    Recent posts

    diff --git a/blog/2015/10/19/reactiflux-is-moving-to-discord.html b/blog/2015/10/19/reactiflux-is-moving-to-discord.html index 2e1f580e68..5d6f441783 100644 --- a/blog/2015/10/19/reactiflux-is-moving-to-discord.html +++ b/blog/2015/10/19/reactiflux-is-moving-to-discord.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -190,6 +191,8 @@

    Recent posts

    diff --git a/blog/2015/10/28/react-v0.14.1.html b/blog/2015/10/28/react-v0.14.1.html index 700cfcb294..6ffd28a09d 100644 --- a/blog/2015/10/28/react-v0.14.1.html +++ b/blog/2015/10/28/react-v0.14.1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -158,6 +159,8 @@ Minified build for production: h

    Recent posts

    diff --git a/blog/2015/11/02/react-v0.14.2.html b/blog/2015/11/02/react-v0.14.2.html index 30011f73f6..8427eeab3b 100644 --- a/blog/2015/11/02/react-v0.14.2.html +++ b/blog/2015/11/02/react-v0.14.2.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -140,6 +141,8 @@ Minified build for production: h

    Recent posts

    diff --git a/blog/2015/11/18/react-v0.14.3.html b/blog/2015/11/18/react-v0.14.3.html index 60ba842055..4c163345e1 100644 --- a/blog/2015/11/18/react-v0.14.3.html +++ b/blog/2015/11/18/react-v0.14.3.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -158,6 +159,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -176,8 +179,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2015/12/04/react-js-conf-2016-diversity-scholarship.html b/blog/2015/12/04/react-js-conf-2016-diversity-scholarship.html index 13d27d2044..6f897fac36 100644 --- a/blog/2015/12/04/react-js-conf-2016-diversity-scholarship.html +++ b/blog/2015/12/04/react-js-conf-2016-diversity-scholarship.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -154,6 +155,8 @@

    Recent posts

    diff --git a/blog/2015/12/16/ismounted-antipattern.html b/blog/2015/12/16/ismounted-antipattern.html index 7991dfb082..8b1bc0205a 100644 --- a/blog/2015/12/16/ismounted-antipattern.html +++ b/blog/2015/12/16/ismounted-antipattern.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -171,6 +172,8 @@

    Recent posts

    diff --git a/blog/2015/12/18/react-components-elements-and-instances.html b/blog/2015/12/18/react-components-elements-and-instances.html index f040cbf6f0..e056cae454 100644 --- a/blog/2015/12/18/react-components-elements-and-instances.html +++ b/blog/2015/12/18/react-components-elements-and-instances.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -461,6 +462,8 @@

    Recent posts

    diff --git a/blog/2015/12/29/react-v0.14.4.html b/blog/2015/12/29/react-v0.14.4.html index a5edd3c48c..3a315ded88 100644 --- a/blog/2015/12/29/react-v0.14.4.html +++ b/blog/2015/12/29/react-v0.14.4.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -87,7 +88,7 @@ by - Ben Alpert + Sophie Alpert @@ -152,6 +153,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -170,8 +173,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2016/01/08/A-implies-B-does-not-imply-B-implies-A.html b/blog/2016/01/08/A-implies-B-does-not-imply-B-implies-A.html index 96dd402206..8a3a41c03c 100644 --- a/blog/2016/01/08/A-implies-B-does-not-imply-B-implies-A.html +++ b/blog/2016/01/08/A-implies-B-does-not-imply-B-implies-A.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -159,6 +160,8 @@

    Recent posts

    diff --git a/blog/2016/01/12/discontinuing-ie8-support.html b/blog/2016/01/12/discontinuing-ie8-support.html index 62d2f7b96e..195a49e78b 100644 --- a/blog/2016/01/12/discontinuing-ie8-support.html +++ b/blog/2016/01/12/discontinuing-ie8-support.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -87,7 +88,7 @@ by - Ben Alpert + Sophie Alpert @@ -114,6 +115,8 @@

    Recent posts

    diff --git a/blog/2016/02/19/new-versioning-scheme.html b/blog/2016/02/19/new-versioning-scheme.html index 9e5089cfe5..4e6a6b9291 100644 --- a/blog/2016/02/19/new-versioning-scheme.html +++ b/blog/2016/02/19/new-versioning-scheme.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -164,6 +165,8 @@

    Recent posts

    diff --git a/blog/2016/03/07/react-v15-rc1.html b/blog/2016/03/07/react-v15-rc1.html index d4a0dbbad9..c9f2aac261 100644 --- a/blog/2016/03/07/react-v15-rc1.html +++ b/blog/2016/03/07/react-v15-rc1.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -206,6 +207,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -224,8 +227,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2016/03/16/react-v15-rc2.html b/blog/2016/03/16/react-v15-rc2.html index 8763e402dd..fc71a59297 100644 --- a/blog/2016/03/16/react-v15-rc2.html +++ b/blog/2016/03/16/react-v15-rc2.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -140,6 +141,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -158,8 +161,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2016/03/29/react-v0.14.8.html b/blog/2016/03/29/react-v0.14.8.html index f9bbf8cc51..21bc95289d 100644 --- a/blog/2016/03/29/react-v0.14.8.html +++ b/blog/2016/03/29/react-v0.14.8.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -141,6 +142,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -159,8 +162,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2016/04/07/react-v15.html b/blog/2016/04/07/react-v15.html index ab81cd129a..90e1dd4ef4 100644 --- a/blog/2016/04/07/react-v15.html +++ b/blog/2016/04/07/react-v15.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -155,7 +156,7 @@ Minified build for production: h

    Note: data-reactid is still present for server-rendered content, however it is much smaller than before and is simply an auto-incrementing counter.

    -

    @spicyj in #5205

    +

    @sophiebits in #5205

  • No more extra <span>s

    Another big change with our DOM interaction is how we render text blocks. Previously you may have noticed that React rendered a lot of extra <span>s. For example, in our most basic example on the home page we render <div>Hello {this.props.name}</div>, resulting in markup that contained 2 <span>s. Now we’ll render plain text nodes interspersed with comment nodes that are used for demarcation. This gives us the same ability to update individual pieces of text, without creating extra nested nodes. Very few people have depended on the actual markup generated here so it’s likely you are not impacted. However if you were targeting these <span>s in your CSS, you will need to adjust accordingly. You can always render them explicitly in your components.

    @@ -165,7 +166,7 @@ Minified build for production: h

    We’ve also made use of these comment nodes to change what null renders to. Rendering to null was a feature we added in React 0.11 and was implemented by rendering <noscript> elements. By rendering to comment nodes now, there’s a chance some of your CSS will be targeting the wrong thing, specifically if you are making use of :nth-child selectors. React’s use of the <noscript> tag has always been considered an implementation detail of how React targets the DOM. We believe they are safe changes to make without going through a release with warnings detailing the subtle differences as they are details that should not be depended upon. Additionally, we have seen that these changes have improved React performance for many typical applications.

    -

    @spicyj in #5451

  • +

    @sophiebits in #5451

  • Functional components can now return null too

    We added support for defining stateless components as functions in React 0.14. However, React 0.14 still allowed you to define a class component without extending React.Component or using React.createClass(), so we couldn’t reliably tell if your component is a function or a class, and did not allow returning null from it. This issue is solved in React 15, and you can now return null from any component, whether it is a class or a function.

    @@ -233,7 +234,7 @@ Minified build for production: h @@ -131,7 +132,7 @@ Minified build for production: h @@ -146,6 +147,8 @@ Minified build for production: h

    Recent posts

    diff --git a/blog/2016/07/11/introducing-reacts-error-code-system.html b/blog/2016/07/11/introducing-reacts-error-code-system.html index 8dc059ae10..11e281a70d 100644 --- a/blog/2016/07/11/introducing-reacts-error-code-system.html +++ b/blog/2016/07/11/introducing-reacts-error-code-system.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -104,7 +105,7 @@

    Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.

    -

    In order to make debugging in production easier, we're introducing an Error Code System in 15.2.0. We developed a gulp script that collects all of our invariant error messages and folds them to a JSON file, and at build-time Babel uses the JSON to rewrite our invariant calls in production to reference the corresponding error IDs. Now when things go wrong in production, the error that React throws will contain a URL with an error ID and relevant information. The URL will point you to a page in our documentation where the original error message gets reassembled.

    +

    In order to make debugging in production easier, we're introducing an Error Code System in 15.2.0. We developed a gulp script that collects all of our invariant error messages and folds them to a JSON file, and at build-time Babel uses the JSON to rewrite our invariant calls in production to reference the corresponding error IDs. Now when things go wrong in production, the error that React throws will contain a URL with an error ID and relevant information. The URL will point you to a page in our documentation where the original error message gets reassembled.

    While we hope you don't see errors often, you can see how it works here. This is what the same error from above will look like:

    @@ -126,6 +127,8 @@

    Recent posts

    diff --git a/blog/2016/07/13/mixins-considered-harmful.html b/blog/2016/07/13/mixins-considered-harmful.html index 0f08684823..2b1d3da231 100644 --- a/blog/2016/07/13/mixins-considered-harmful.html +++ b/blog/2016/07/13/mixins-considered-harmful.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -672,6 +673,8 @@

    Recent posts

    diff --git a/blog/2016/07/22/create-apps-with-no-configuration.html b/blog/2016/07/22/create-apps-with-no-configuration.html index 4e1158483c..afff1da396 100644 --- a/blog/2016/07/22/create-apps-with-no-configuration.html +++ b/blog/2016/07/22/create-apps-with-no-configuration.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -262,6 +263,8 @@ The console output is tuned to be minimal to help you focus on the problems:

    Recent posts

    diff --git a/blog/2016/08/05/relay-state-of-the-state.html b/blog/2016/08/05/relay-state-of-the-state.html index 1e91524479..43c5e8b1c3 100644 --- a/blog/2016/08/05/relay-state-of-the-state.html +++ b/blog/2016/08/05/relay-state-of-the-state.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -114,7 +115,7 @@

    We've also seen some great open-source projects spring up around Relay:

    @@ -195,6 +196,8 @@

    Recent posts

    diff --git a/blog/2016/09/28/our-first-50000-stars.html b/blog/2016/09/28/our-first-50000-stars.html index 3d67c379e7..2a53c7d234 100644 --- a/blog/2016/09/28/our-first-50000-stars.html +++ b/blog/2016/09/28/our-first-50000-stars.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -335,6 +336,8 @@ I think we should just treat arrays of elements as a frag. This is useful for co

    Recent posts

    diff --git a/blog/2016/11/16/react-v15.4.0.html b/blog/2016/11/16/react-v15.4.0.html index 10ccad5536..4ec81a43d8 100644 --- a/blog/2016/11/16/react-v15.4.0.html +++ b/blog/2016/11/16/react-v15.4.0.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -281,6 +282,8 @@ Minified build for production: React v16.0
  • +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -299,8 +302,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2017/04/07/react-v15.5.0.html b/blog/2017/04/07/react-v15.5.0.html index 7cb443e2bb..6a0570e7cb 100644 --- a/blog/2017/04/07/react-v15.5.0.html +++ b/blog/2017/04/07/react-v15.5.0.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -320,6 +321,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -338,8 +341,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2017/05/18/whats-new-in-create-react-app.html b/blog/2017/05/18/whats-new-in-create-react-app.html index 307205b779..f7760f0814 100644 --- a/blog/2017/05/18/whats-new-in-create-react-app.html +++ b/blog/2017/05/18/whats-new-in-create-react-app.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -220,6 +221,8 @@

    Recent posts

    diff --git a/blog/2017/06/13/react-v15.6.0.html b/blog/2017/06/13/react-v15.6.0.html index 8d2a044785..b7190165f9 100644 --- a/blog/2017/06/13/react-v15.6.0.html +++ b/blog/2017/06/13/react-v15.6.0.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -203,6 +204,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -221,8 +224,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2017/07/26/error-handling-in-react-16.html b/blog/2017/07/26/error-handling-in-react-16.html index 84ae07aced..886ceca544 100644 --- a/blog/2017/07/26/error-handling-in-react-16.html +++ b/blog/2017/07/26/error-handling-in-react-16.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -206,6 +207,8 @@

    Recent posts

    diff --git a/blog/2017/09/08/dom-attributes-in-react-16.html b/blog/2017/09/08/dom-attributes-in-react-16.html index acb7313740..c5312261d4 100644 --- a/blog/2017/09/08/dom-attributes-in-react-16.html +++ b/blog/2017/09/08/dom-attributes-in-react-16.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -247,6 +248,8 @@ It uses React 16 RC, and you can React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -265,8 +268,6 @@ It uses React 16 RC, and you can Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2017/09/25/react-v15.6.2.html b/blog/2017/09/25/react-v15.6.2.html index de1abb853a..4e3a126435 100644 --- a/blog/2017/09/25/react-v15.6.2.html +++ b/blog/2017/09/25/react-v15.6.2.html @@ -37,6 +37,7 @@ + @@ -64,7 +65,7 @@ @@ -169,6 +170,8 @@ Minified build for production: React v16.0 +
  • React v15.6.2
  • DOM Attributes in React 16
  • @@ -187,8 +190,6 @@ Minified build for production: Relay: State of the State -
  • Create Apps with No Configuration
  • -
  • All posts ...
  • diff --git a/blog/2017/09/26/react-v16.0.html b/blog/2017/09/26/react-v16.0.html new file mode 100644 index 0000000000..7aa3fa0e7e --- /dev/null +++ b/blog/2017/09/26/react-v16.0.html @@ -0,0 +1,404 @@ + + + + + + + + + React v16.0 - React Blog + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    + +
    + + +

    + + React v16.0 + +

    + +

    + September 26, 2017 + by + + + Andrew Clark + + + +

    + +
    + +
    +

    We're excited to announce the release of React v16.0! Among the changes are some long-standing feature requests, including fragments, error boundaries, portals, support for custom DOM attributes, improved server-side rendering, and reduced file size.

    + +

    New render return types: fragments and strings

    + +

    You can now return an array of elements from a component's render method. Like with other arrays, you'll need to add a key to each element to avoid the key warning:

    +
    render() {
    +  // No need to wrap list items in an extra element!
    +  return [
    +    // Don't forget the keys :)
    +    <li key="A">First item</li>,
    +    <li key="B">Second item</li>,
    +    <li key="C">Third item</li>,
    +  ];
    +}
    +
    +

    In the future, we'll likely add a special fragment syntax to JSX that doesn't require keys.

    + +

    We've added support for returning strings, too:

    +
    render() {
    +  return 'Look ma, no spans!';
    +}
    +
    +

    See the full list of supported return types.

    + +

    Better error handling

    + +

    Previously, runtime errors during rendering could put React in a broken state, producing cryptic error messages and requiring a page refresh to recover. To address this problem, React 16 uses a more resilient error-handling strategy. By default, if an error is thrown inside a component's render or lifecycle methods, the whole component tree is unmounted from the root. This prevents the display of corrupted data. However, it's probably not the ideal user experience.

    + +

    Instead of unmounting the whole app every time there's an error, you can use error boundaries. Error boundaries are special components that capture errors inside their subtree and display a fallback UI in its place. Think of error boundaries like try-catch statements, but for React components.

    + +

    For more details, check out our previous post on error handling in React 16.

    + +

    Portals

    + +

    Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.

    +
    render() {
    +  // React does *not* create a new div. It renders the children into `domNode`.
    +  // `domNode` is any valid DOM node, regardless of its location in the DOM.
    +  return ReactDOM.createPortal(
    +    this.props.children,
    +    domNode,
    +  );
    +}
    +
    +

    See a full example in the documentation for portals.

    + +

    Better server-side rendering

    + +

    React 16 includes a completely rewritten server renderer. It's really fast. It supports streaming, so you can start sending bytes to the client faster. And thanks to a new packaging strategy that compiles away process.env checks (Believe it or not, reading process.env in Node is really slow!), you no longer need to bundle React to get good server-rendering performance.

    + +

    Core team member Sasha Aickin wrote a great article describing React 16's SSR improvements. According to Sasha's synthetic benchmarks, server rendering in React 16 is roughly three times faster than React 15. "When comparing against React 15 with process.env compiled out, there’s about a 2.4x improvement in Node 4, about a 3x performance improvement in Node 6, and a full 3.8x improvement in the new Node 8.4 release. And if you compare against React 15 without compilation, React 16 has a full order of magnitude gain in SSR in the latest version of Node!" (As Sasha points out, please be aware that these numbers are based on synthetic benchmarks and may not reflect real-world performance.)

    + +

    In addition, React 16 is better at hydrating server-rendered HTML once it reaches the client. It no longer requires the initial render to exactly match the result from the server. Instead, it will attempt to reuse as much of the existing DOM as possible. No more checksums! In general, we don't recommend that you render different content on the client versus the server, but it can be useful in some cases (e.g. timestamps).

    + +

    See the documentation for ReactDOMServer for more details.

    + +

    Support for custom DOM attributes

    + +

    Instead of ignoring unrecognized HTML and SVG attributes, React will now pass them through to the DOM. This has the added benefit of allowing us to get rid of most of React's attribute whitelist, resulting in reduced file sizes.

    + +

    Reduced file size

    + +

    Despite all these additions, React 16 is actually smaller compared to 15.6.1!

    + +
      +
    • react is 5.3 kb (2.2 kb gzipped), down from 20.7 kb (6.9 kb gzipped).
    • +
    • react-dom is 103.7 kb (32.6 kb gzipped), down from 141 kb (42.9 kb gzipped).
    • +
    • react + react-dom is 109 kb (34.8 kb gzipped), down from 161.7 kb (49.8 kb gzipped).
    • +
    + +

    That amounts to a combined 32% size decrease compared to the previous version (30% post-gzip).

    + +

    The size difference is partly attributable to a change in packaging. React now uses Rollup to create flat bundles for each of its different target formats, resulting in both size and runtime performance wins. The flat bundle format also means that React's impact on bundle size is roughly consistent regardless of how your ship your app, whether it's with Webpack, Browserify, the pre-built UMD bundles, or any other system.

    + +

    MIT licensed

    + +

    In case you missed it, React 16 is available under the MIT license. We've also published React 15.6.2 under MIT, for those who are unable to upgrade immediately.

    + +

    New core architecture

    + +

    React 16 is the first version of React built on top of a new core architecture, codenamed "Fiber." You can read all about this project over on Facebook's engineering blog. (Spoiler: we rewrote React!)

    + +

    Fiber is responsible for most of the new features in React 16, like error boundaries and fragments. Over the next few releases, you can expect more new features as we begin to unlock the full potential of React.

    + +

    Perhaps the most exciting area we're working on is async rendering—a strategy for cooperatively scheduling rendering work by periodically yielding execution to the browser. The upshot is that, with async rendering, apps are more responsive because React avoids blocking the main thread.

    + +

    This demo provides an early peek at the types of problems async rendering can solve:

    + + + + + +

    Tip: Pay attention to the spinning black square.

    + +

    We think async rendering is a big deal, and represents the future of React. To make migration to v16.0 as smooth as possible, we're not enabling any async features yet, but we're excited to start rolling them out in the coming months. Stay tuned!

    + +

    Installation

    + +

    React v16.0.0 is available on the npm registry.

    + +

    To install React 16 with Yarn, run:

    +
    yarn add react@^16.0.0 react-dom@^16.0.0
    +
    +

    To install React 16 with npm, run:

    +
    npm install --save react@^16.0.0 react-dom@^16.0.0
    +
    +

    We also provide UMD builds of React via a CDN:

    +
    <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
    +<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
    +
    +

    Refer to the documentation for detailed installation instructions.

    + +

    Upgrading

    + +

    Although React 16 includes significant internal changes, in terms of upgrading, you can think of this like any other major React release. We've been serving React 16 to Facebook and Messenger.com users since earlier this year, and we released several beta and release candidate versions to flush out additional issues. With minor exceptions, if your app runs in 15.6 without any warnings, it should work in 16.

    + +

    New deprecations

    + +

    Hydrating a server-rendered container now has an explicit API. If you're reviving server-rendered HTML, use ReactDOM.hydrate instead of ReactDOM.render. Keep using ReactDOM.render if you're just doing client-side rendering.

    + +

    React Addons

    + +

    As previously announced, we've discontinued support for React Addons. We expect the latest version of each addon (except react-addons-perf; see below) to work for the foreseeable future, but we won't publish additional updates.

    + +

    Refer to the previous announcement for suggestions on how to migrate.

    + +

    react-addons-perf no longer works at all in React 16. It's likely that we'll release a new version of this tool in the future. In the meantime, you can use your browser's performance tools to profile React components.

    + +

    Breaking changes

    + +

    React 16 includes a number of small breaking changes. These only affect uncommon use cases and we don't expect them to break most apps.

    + +
      +
    • React 15 had limited, undocumented support for error boundaries using unstable_handleError. This method has been renamed to componentDidCatch. You can use a codemod to automatically migrate to the new API.
    • +
    • ReactDOM.render and ReactDOM.unstable_renderIntoContainer now return null if called from inside a lifecycle method. To work around this, you can use portals or refs.
    • +
    • setState: + +
        +
      • Calling setState with null no longer triggers an update. This allows you to decide in an updater function if you want to re-render.
      • +
      • Calling setState directly in render always causes an update. This was not previously the case. Regardless, you should not be calling setState from render.
      • +
      • setState callbacks (second argument) now fire immediately after componentDidMount / componentDidUpdate instead of after all components have rendered.
      • +
    • +
    • When replacing <A /> with <B />, B.componentWillMount now always happens before A.componentWillUnmount. Previously, A.componentWillUnmount could fire first in some cases.
    • +
    • Previously, changing the ref to a component would always detach the ref before that component's render is called. Now, we change the ref later, when applying the changes to the DOM.
    • +
    • It is not safe to re-render into a container that was modified by something other than React. This worked previously in some cases but was never supported. We now emit a warning in this case. Instead you should clean up your component trees using ReactDOM.unmountComponentAtNode. See this example.
    • +
    • componentDidUpdate lifecycle no longer receives prevContext param. (See #8631)
    • +
    • Shallow renderer no longer calls componentDidUpdate because DOM refs are not available. This also makes it consistent with componentDidMount (which does not get called in previous versions either).
    • +
    • Shallow renderer does not implement unstable_batchedUpdates anymore.
    • +
    + +

    Packaging

    + +
      +
    • There is no react/lib/* and react-dom/lib/* anymore. Even in CommonJS environments, React and ReactDOM are precompiled to single files (“flat bundles”). If you previously relied on undocumented React internals, and they don’t work anymore, let us know about your specific case in a new issue, and we’ll try to figure out a migration strategy for you.
    • +
    • There is no react-with-addons.js build anymore. All compatible addons are published separately on npm, and have single-file browser versions if you need them.
    • +
    • The deprecations introduced in 15.x have been removed from the core package. React.createClass is now available as create-react-class, React.PropTypes as prop-types, React.DOM as react-dom-factories, react-addons-test-utils as react-dom/test-utils, and shallow renderer as react-test-renderer/shallow. See 15.5.0 and 15.6.0 blog posts for instructions on migrating code and automated codemods.
    • +
    • The names and paths to the single-file browser builds have changed to emphasize the difference between development and production builds. For example: + +
        +
      • react/dist/react.jsreact/umd/react.development.js
      • +
      • react/dist/react.min.jsreact/umd/react.production.min.js
      • +
      • react-dom/dist/react-dom.jsreact-dom/umd/react-dom.development.js
      • +
      • react-dom/dist/react-dom.min.js → react-dom/umd/react-dom.production.min.js
      • +
    • +
    + +

    JavaScript Environment Requirements

    + +

    React 16 depends on the collection types Map and Set. If you support older browsers and devices which may not yet provide these natively (e.g. IE < 11), consider including a global polyfill in your bundled application, such as core-js or babel-polyfill.

    + +

    A polyfilled environment for React 16 using core-js to support older browsers might look like:

    +
    import 'core-js/es6/map';
    +import 'core-js/es6/set';
    +
    +import React from 'react';
    +import ReactDOM from 'react-dom';
    +
    +ReactDOM.render(
    +  <h1>Hello, world!</h1>,
    +  document.getElementById('root')
    +);
    +
    +

    React also depends on requestAnimationFrame (even in test environments). A simple shim for test environments would be:

    +
    global.requestAnimationFrame = function(callback) {
    +  setTimeout(callback, 0);
    +};
    +
    +

    Acknowledgments

    + +

    As always, this release would not have been possible without our open source contributors. Thanks to everyone who filed bugs, opened PRs, responded to issues, wrote documentation, and more!

    + +

    Special thanks to our core contributors, especially for their heroic efforts over the past few weeks during the prerelease cycle: Brandon Dail, Jason Quense, Nathan Hunzaker, and Sasha Aickin.

    + +
    + + +
    + + +
    + + +
    + + + + +
    + +
    + + + + diff --git a/blog/all.html b/blog/all.html index ef79e5a2b4..dc8cbe7106 100644 --- a/blog/all.html +++ b/blog/all.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -74,6 +75,13 @@

    All Posts

    +

    React v16.0 on September 26, 2017 by + + Andrew Clark + + +

    +

    React v15.6.2 on September 25, 2017 by Nathan Hunzaker @@ -202,7 +210,7 @@

    Discontinuing IE 8 Support in React DOM on January 12, 2016 by - Ben Alpert + Sophie Alpert

    @@ -216,7 +224,7 @@

    React v0.14.4 on December 29, 2015 by - Ben Alpert + Sophie Alpert

    @@ -272,7 +280,7 @@

    React v0.14 on October 7, 2015 by - Ben Alpert + Sophie Alpert

    @@ -296,14 +304,14 @@

    React v0.14 Release Candidate on September 10, 2015 by - Ben Alpert + Sophie Alpert

    New React Developer Tools on September 2, 2015 by - Ben Alpert + Sophie Alpert

    @@ -331,7 +339,7 @@

    React v0.14 Beta 1 on July 3, 2015 by - Ben Alpert + Sophie Alpert

    @@ -387,7 +395,7 @@

    Introducing React Native on March 26, 2015 by - Ben Alpert + Sophie Alpert

    @@ -408,7 +416,7 @@

    React v0.13 on March 10, 2015 by - Ben Alpert + Sophie Alpert

    @@ -663,14 +671,14 @@

    React v0.9 on February 20, 2014 by - Ben Alpert + Sophie Alpert

    React v0.9 RC on February 16, 2014 by - Ben Alpert + Sophie Alpert

    diff --git a/blog/index.html b/blog/index.html index bb91eb216a..c9beb38d33 100644 --- a/blog/index.html +++ b/blog/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@
    @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,228 @@
    +

    + + React v16.0 + +

    + +

    + September 26, 2017 + by + + + Andrew Clark + + + +

    + +
    + +
    +

    We're excited to announce the release of React v16.0! Among the changes are some long-standing feature requests, including fragments, error boundaries, portals, support for custom DOM attributes, improved server-side rendering, and reduced file size.

    + +

    New render return types: fragments and strings

    + +

    You can now return an array of elements from a component's render method. Like with other arrays, you'll need to add a key to each element to avoid the key warning:

    +
    render() {
    +  // No need to wrap list items in an extra element!
    +  return [
    +    // Don't forget the keys :)
    +    <li key="A">First item</li>,
    +    <li key="B">Second item</li>,
    +    <li key="C">Third item</li>,
    +  ];
    +}
    +
    +

    In the future, we'll likely add a special fragment syntax to JSX that doesn't require keys.

    + +

    We've added support for returning strings, too:

    +
    render() {
    +  return 'Look ma, no spans!';
    +}
    +
    +

    See the full list of supported return types.

    + +

    Better error handling

    + +

    Previously, runtime errors during rendering could put React in a broken state, producing cryptic error messages and requiring a page refresh to recover. To address this problem, React 16 uses a more resilient error-handling strategy. By default, if an error is thrown inside a component's render or lifecycle methods, the whole component tree is unmounted from the root. This prevents the display of corrupted data. However, it's probably not the ideal user experience.

    + +

    Instead of unmounting the whole app every time there's an error, you can use error boundaries. Error boundaries are special components that capture errors inside their subtree and display a fallback UI in its place. Think of error boundaries like try-catch statements, but for React components.

    + +

    For more details, check out our previous post on error handling in React 16.

    + +

    Portals

    + +

    Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.

    +
    render() {
    +  // React does *not* create a new div. It renders the children into `domNode`.
    +  // `domNode` is any valid DOM node, regardless of its location in the DOM.
    +  return ReactDOM.createPortal(
    +    this.props.children,
    +    domNode,
    +  );
    +}
    +
    +

    See a full example in the documentation for portals.

    + +

    Better server-side rendering

    + +

    React 16 includes a completely rewritten server renderer. It's really fast. It supports streaming, so you can start sending bytes to the client faster. And thanks to a new packaging strategy that compiles away process.env checks (Believe it or not, reading process.env in Node is really slow!), you no longer need to bundle React to get good server-rendering performance.

    + +

    Core team member Sasha Aickin wrote a great article describing React 16's SSR improvements. According to Sasha's synthetic benchmarks, server rendering in React 16 is roughly three times faster than React 15. "When comparing against React 15 with process.env compiled out, there’s about a 2.4x improvement in Node 4, about a 3x performance improvement in Node 6, and a full 3.8x improvement in the new Node 8.4 release. And if you compare against React 15 without compilation, React 16 has a full order of magnitude gain in SSR in the latest version of Node!" (As Sasha points out, please be aware that these numbers are based on synthetic benchmarks and may not reflect real-world performance.)

    + +

    In addition, React 16 is better at hydrating server-rendered HTML once it reaches the client. It no longer requires the initial render to exactly match the result from the server. Instead, it will attempt to reuse as much of the existing DOM as possible. No more checksums! In general, we don't recommend that you render different content on the client versus the server, but it can be useful in some cases (e.g. timestamps).

    + +

    See the documentation for ReactDOMServer for more details.

    + +

    Support for custom DOM attributes

    + +

    Instead of ignoring unrecognized HTML and SVG attributes, React will now pass them through to the DOM. This has the added benefit of allowing us to get rid of most of React's attribute whitelist, resulting in reduced file sizes.

    + +

    Reduced file size

    + +

    Despite all these additions, React 16 is actually smaller compared to 15.6.1!

    + + + +

    That amounts to a combined 32% size decrease compared to the previous version (30% post-gzip).

    + +

    The size difference is partly attributable to a change in packaging. React now uses Rollup to create flat bundles for each of its different target formats, resulting in both size and runtime performance wins. The flat bundle format also means that React's impact on bundle size is roughly consistent regardless of how your ship your app, whether it's with Webpack, Browserify, the pre-built UMD bundles, or any other system.

    + +

    MIT licensed

    + +

    In case you missed it, React 16 is available under the MIT license. We've also published React 15.6.2 under MIT, for those who are unable to upgrade immediately.

    + +

    New core architecture

    + +

    React 16 is the first version of React built on top of a new core architecture, codenamed "Fiber." You can read all about this project over on Facebook's engineering blog. (Spoiler: we rewrote React!)

    + +

    Fiber is responsible for most of the new features in React 16, like error boundaries and fragments. Over the next few releases, you can expect more new features as we begin to unlock the full potential of React.

    + +

    Perhaps the most exciting area we're working on is async rendering—a strategy for cooperatively scheduling rendering work by periodically yielding execution to the browser. The upshot is that, with async rendering, apps are more responsive because React avoids blocking the main thread.

    + +

    This demo provides an early peek at the types of problems async rendering can solve:

    + + + + + +

    Tip: Pay attention to the spinning black square.

    + +

    We think async rendering is a big deal, and represents the future of React. To make migration to v16.0 as smooth as possible, we're not enabling any async features yet, but we're excited to start rolling them out in the coming months. Stay tuned!

    + +

    Installation

    + +

    React v16.0.0 is available on the npm registry.

    + +

    To install React 16 with Yarn, run:

    +
    yarn add react@^16.0.0 react-dom@^16.0.0
    +
    +

    To install React 16 with npm, run:

    +
    npm install --save react@^16.0.0 react-dom@^16.0.0
    +
    +

    We also provide UMD builds of React via a CDN:

    +
    <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
    +<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
    +
    +

    Refer to the documentation for detailed installation instructions.

    + +

    Upgrading

    + +

    Although React 16 includes significant internal changes, in terms of upgrading, you can think of this like any other major React release. We've been serving React 16 to Facebook and Messenger.com users since earlier this year, and we released several beta and release candidate versions to flush out additional issues. With minor exceptions, if your app runs in 15.6 without any warnings, it should work in 16.

    + +

    New deprecations

    + +

    Hydrating a server-rendered container now has an explicit API. If you're reviving server-rendered HTML, use ReactDOM.hydrate instead of ReactDOM.render. Keep using ReactDOM.render if you're just doing client-side rendering.

    + +

    React Addons

    + +

    As previously announced, we've discontinued support for React Addons. We expect the latest version of each addon (except react-addons-perf; see below) to work for the foreseeable future, but we won't publish additional updates.

    + +

    Refer to the previous announcement for suggestions on how to migrate.

    + +

    react-addons-perf no longer works at all in React 16. It's likely that we'll release a new version of this tool in the future. In the meantime, you can use your browser's performance tools to profile React components.

    + +

    Breaking changes

    + +

    React 16 includes a number of small breaking changes. These only affect uncommon use cases and we don't expect them to break most apps.

    + + + +

    Packaging

    + + + +

    JavaScript Environment Requirements

    + +

    React 16 depends on the collection types Map and Set. If you support older browsers and devices which may not yet provide these natively (e.g. IE < 11), consider including a global polyfill in your bundled application, such as core-js or babel-polyfill.

    + +

    A polyfilled environment for React 16 using core-js to support older browsers might look like:

    +
    import 'core-js/es6/map';
    +import 'core-js/es6/set';
    +
    +import React from 'react';
    +import ReactDOM from 'react-dom';
    +
    +ReactDOM.render(
    +  <h1>Hello, world!</h1>,
    +  document.getElementById('root')
    +);
    +
    +

    React also depends on requestAnimationFrame (even in test environments). A simple shim for test environments would be:

    +
    global.requestAnimationFrame = function(callback) {
    +  setTimeout(callback, 0);
    +};
    +
    +

    Acknowledgments

    + +

    As always, this release would not have been possible without our open source contributors. Thanks to everyone who filed bugs, opened PRs, responded to issues, wrote documentation, and more!

    + +

    Special thanks to our core contributors, especially for their heroic efforts over the past few weeks during the prerelease cycle: Brandon Dail, Jason Quense, Nathan Hunzaker, and Sasha Aickin.

    + +
    + + + +
    + +
    + +

    React v15.6.2 @@ -610,147 +833,6 @@ Minified build for production: - - -

    - - What's New in Create React App - -

    - -

    - May 18, 2017 - by - - - Dan Abramov - - - -

    - -
    - -
    -

    Less than a year ago, we introduced Create React App as an officially supported way to create apps with zero configuration. The project has since enjoyed tremendous growth, with over 950 commits by more than 250 contributors.

    - -

    Today, we are excited to announce that many features that have been in the pipeline for the last few months are finally released.

    - -

    As usual with Create React App, you can enjoy these improvements in your existing non-ejected apps by updating a single dependency and following our migration instructions.

    - -

    Newly created apps will get these improvements automatically.

    - -

    webpack 2

    - -
    -

    This change was contributed by @Timer in #1291.

    -
    - -

    We have upgraded to webpack 2 which has been officially released a few months ago. It is a big upgrade with many bugfixes and general improvements. We have been testing it for a while, and now consider it stable enough to recommend it to everyone.

    - -

    While the Webpack configuration format has changed, Create React App users who didn't eject don't need to worry about it as we have updated the configuration on our side.

    - -

    If you had to eject your app for one reason or another, Webpack provides a configuration migration guide that you can follow to update your apps. Note that with each release of Create React App, we are working to support more use cases out of the box so that you don't have to eject in the future.

    - -

    The biggest notable webpack 2 feature is the ability to write and import ES6 modules directly without compiling them to CommonJS. This shouldn’t affect how you write code since you likely already use import and export statements, but it will help catch more mistakes like missing named exports at compile time:

    - -

    Export validation

    - -

    In the future, as the ecosystem around ES6 modules matures, you can expect more improvements to your app's bundle size thanks to tree shaking.

    - -

     Runtime Error Overlay

    - -
    -

    This change was contributed by @Timer and @nicinabox in #1101, @bvaughn in #2201.

    -
    - -

    Have you ever made a mistake in code and only realized it after the console is flooded with cryptic errors? Or worse, have you ever shipped an app with crashes in production because you accidentally missed an error in development?

    - -

    To address these issues, we are introducing an overlay that pops up whenever there is an uncaught error in your application. It only appears in development, and you can dismiss it by pressing Escape.

    - -

    A GIF is worth a thousand words:

    - -

    Runtime error overlay

    - -

    (Yes, it integrates with your editor!)

    - -

    In the future, we plan to teach the runtime error overlay to understand more about your React app. For example, after React 16 we plan to show React component stacks in addition to the JavaScript stacks when an error is thrown.

    - -

    Progressive Web Apps by Default

    - -
    -

    This change was contributed by @jeffposnick in #1728.

    -
    - -

    Newly created projects are built as Progressive Web Apps by default. This means that they employ service workers with an offline-first caching strategy to minimize the time it takes to serve the app to the users who visit it again. You can opt out of this behavior, but we recommend it both for new and existing apps, especially if you target mobile devices.

    - -

    Loading assets from service worker

    - -

    New apps automatically have these features, but you can easily convert an existing project to a Progressive Web App by following our migration guide.

    - -

    We will be adding more documentation on this topic in the coming weeks. Please feel free to ask any questions on the issue tracker!

    - -

    Jest 20

    - -
    -

    This change was contributed by @rogeliog in #1614 and @gaearon in #2171.

    -
    - -

    We are now using the latest version of Jest that includes numerous bugfixes and improvements. You can read more about the changes in Jest 19 and Jest 20 blog posts.

    - -

    Highlights include a new immersive watch mode, a better snapshot format, improvements to printing skipped tests, and new testing APIs.

    - -

    Immersive test watcher

    - -

    Additionally, Create React App now support configuring a few Jest options related to coverage reporting.

    - -

    Code Splitting with Dynamic import()

    - -
    -

    This change was contributed by @Timer in #1538 and @tharakawj in #1801.

    -
    - -

    It is important to keep the initial JavaScript payload of web apps down to the minimum, and load the rest of the code on demand. Although Create React App supported code splitting using require.ensure() since the first release, it used a webpack-specific syntax that did not work in Jest or other environments.

    - -

    In this release, we are adding support for the dynamic import() proposal which aligns with the future web standards. Unlike require.ensure(), it doesn't break Jest tests, and should eventually become a part of JavaScript. We encourage you to use import() to delay loading the code for non-critical component subtrees until you need to render them.

    - -

    Creating chunks with dynamic import

    - -

    Better Console Output

    - -
    -

    This change was contributed by @gaearon in #2120, #2125, and #2161.

    -
    - -

    We have improved the console output across the board.

    - -

    For example, when you start the development server, we now display the LAN address in additional to the localhost address so that you can quickly access the app from a mobile device on the same network:

    - -

    Better console output

    - -

    When lint errors are reported, we no longer show the warnings so that you can concentrate on more critical issues. Errors and warnings in the production build output are better formatted, and the build error overlay font size now matches the browser font size more closely.

    - -

    But Wait... There's More!

    - -

    You can only fit so much in a blog post, but there are other long-requested features in this release, such as environment-specific and local .env files, a lint rule against confusingly named globals, support for multiple proxies in development, a customizable browser launch script, and many bugfixes.

    - -

    You can read the full changelog and the migration guide in the v1.0.0 release notes.

    - -

    Acknowledgements

    - -

    This release is a result of months of work from many people in the React community. It is focused on improving both developer and end user experience, as we believe they are complementary and go hand in hand.

    - -

    We are grateful to everyone who has offered their contributions, whether in code, documentation, or by helping other people. We would like to specifically thank Joe Haddad for his invaluable help maintaining the project.

    - -

    We are excited to bring these improvements to everybody using Create React App, and we are looking forward to more of your feedback and contributions.

    - -
    - - -

    diff --git a/blog/page10/index.html b/blog/page10/index.html index 042ec40536..213434a57c 100644 --- a/blog/page10/index.html +++ b/blog/page10/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,49 @@
    +

    + + Introducing React Native + +

    + +

    + March 26, 2015 + by + + + Sophie Alpert + + + +

    + +
    + +
    +

    In January at React.js Conf, we announced React Native, a new framework for building native apps using React. We're happy to announce that we're open-sourcing React Native and you can start building your apps with it today.

    + +

    For more details, see Tom Occhino's post on the Facebook Engineering blog:

    + +
    +

    What we really want is the user experience of the native mobile platforms, combined with the developer experience we have when building with React on the web.

    + +

    With a bit of work, we can make it so the exact same React that's on GitHub can power truly native mobile applications. The only difference in the mobile environment is that instead of running React in the browser and rendering to divs and spans, we run it an embedded instance of JavaScriptCore inside our apps and render to higher-level platform-specific components.

    + +

    It's worth noting that we're not chasing “write once, run anywhere.” Different platforms have different looks, feels, and capabilities, and as such, we should still be developing discrete apps for each platform, but the same set of engineers should be able to build applications for whatever platform they choose, without needing to learn a fundamentally different set of technologies for each. We call this approach “learn once, write anywhere.”

    +
    + +

    To learn more, visit the React Native website.

    + +
    + + + +
    + +
    + +

    Building The Facebook News Feed With Relay @@ -424,7 +468,7 @@ Minified build for production: Ben Alpert + Sophie Alpert @@ -629,86 +673,6 @@ Minified build for production: - - -

    - - React v0.13 RC2 - -

    - -

    - March 3, 2015 - by - - - Sebastian Markbåge - - - -

    - -
    - -
    -

    Thanks to everybody who has already been testing the release candidate. We've received some good feedback and as a result we're going to do a second release candidate. The changes are minimal. We haven't changed the behavior of any APIs we exposed in the previous release candidate. Here's a summary of the changes:

    - -
      -
    • Introduced a new API (React.cloneElement, see below for details).
    • -
    • Fixed a bug related to validating propTypes when using the new React.addons.createFragment API.
    • -
    • Improved a couple warning messages.
    • -
    • Upgraded jstransform and esprima.
    • -
    - -

    The release candidate is available for download:

    - - - -

    We've also published version 0.13.0-rc2 of the react and react-tools packages on npm and the react package on bower.

    - -
    - -

    React.cloneElement

    - -

    In React v0.13 RC2 we will introduce a new API, similar to React.addons.cloneWithProps, with this signature:

    -
    React.cloneElement(element, props, ...children);
    -
    -

    Unlike cloneWithProps, this new function does not have any magic built-in behavior for merging style and className for the same reason we don't have that feature from transferPropsTo. Nobody is sure what exactly the complete list of magic things are, which makes it difficult to reason about the code and difficult to reuse when style has a different signature (e.g. in the upcoming React Native).

    - -

    React.cloneElement is almost equivalent to:

    -
    <element.type {...element.props} {...props}>{children}</element.type>
    -
    -

    However, unlike JSX and cloneWithProps, it also preserves refs. This means that if you get a child with a ref on it, you won't accidentally steal it from your ancestor. You will get the same ref attached to your new element.

    - -

    One common pattern is to map over your children and add a new prop. There were many issues reported about cloneWithProps losing the ref, making it harder to reason about your code. Now following the same pattern with cloneElement will work as expected. For example:

    -
    var newChildren = React.Children.map(this.props.children, function(child) {
    -  return React.cloneElement(child, { foo: true })
    -});
    -
    -
    -

    Note: React.cloneElement(child, { ref: 'newRef' }) DOES override the ref so it is still not possible for two parents to have a ref to the same child, unless you use callback-refs.

    -
    - -

    This was a critical feature to get into React 0.13 since props are now immutable. The upgrade path is often to clone the element, but by doing so you might lose the ref. Therefore, we needed a nicer upgrade path here. As we were upgrading callsites at Facebook we realized that we needed this method. We got the same feedback from the community. Therefore we decided to make another RC before the final release to make sure we get this in.

    - -

    We plan to eventually deprecate React.addons.cloneWithProps. We're not doing it yet, but this is a good opportunity to start thinking about your own uses and consider using React.cloneElement instead. We'll be sure to ship a release with deprecation notices before we actually remove it so no immediate action is necessary.

    - -
    - - -

    diff --git a/blog/page11/index.html b/blog/page11/index.html index 3156206d21..4c67bd7d5e 100644 --- a/blog/page11/index.html +++ b/blog/page11/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,86 @@
    +

    + + React v0.13 RC2 + +

    + +

    + March 3, 2015 + by + + + Sebastian Markbåge + + + +

    + +
    + +
    +

    Thanks to everybody who has already been testing the release candidate. We've received some good feedback and as a result we're going to do a second release candidate. The changes are minimal. We haven't changed the behavior of any APIs we exposed in the previous release candidate. Here's a summary of the changes:

    + + + +

    The release candidate is available for download:

    + + + +

    We've also published version 0.13.0-rc2 of the react and react-tools packages on npm and the react package on bower.

    + +
    + +

    React.cloneElement

    + +

    In React v0.13 RC2 we will introduce a new API, similar to React.addons.cloneWithProps, with this signature:

    +
    React.cloneElement(element, props, ...children);
    +
    +

    Unlike cloneWithProps, this new function does not have any magic built-in behavior for merging style and className for the same reason we don't have that feature from transferPropsTo. Nobody is sure what exactly the complete list of magic things are, which makes it difficult to reason about the code and difficult to reuse when style has a different signature (e.g. in the upcoming React Native).

    + +

    React.cloneElement is almost equivalent to:

    +
    <element.type {...element.props} {...props}>{children}</element.type>
    +
    +

    However, unlike JSX and cloneWithProps, it also preserves refs. This means that if you get a child with a ref on it, you won't accidentally steal it from your ancestor. You will get the same ref attached to your new element.

    + +

    One common pattern is to map over your children and add a new prop. There were many issues reported about cloneWithProps losing the ref, making it harder to reason about your code. Now following the same pattern with cloneElement will work as expected. For example:

    +
    var newChildren = React.Children.map(this.props.children, function(child) {
    +  return React.cloneElement(child, { foo: true })
    +});
    +
    +
    +

    Note: React.cloneElement(child, { ref: 'newRef' }) DOES override the ref so it is still not possible for two parents to have a ref to the same child, unless you use callback-refs.

    +
    + +

    This was a critical feature to get into React 0.13 since props are now immutable. The upgrade path is often to clone the element, but by doing so you might lose the ref. Therefore, we needed a nicer upgrade path here. As we were upgrading callsites at Facebook we realized that we needed this method. We got the same feedback from the community. Therefore we decided to make another RC before the final release to make sure we get this in.

    + +

    We plan to eventually deprecate React.addons.cloneWithProps. We're not doing it yet, but this is a good opportunity to start thinking about your own uses and consider using React.cloneElement instead. We'll be sure to ship a release with deprecation notices before we actually remove it so no immediate action is necessary.

    + +
    + + + +
    + +
    + +

    React v0.13 RC @@ -780,7 +861,7 @@ Minified build for production:

    Core Team Q&A #

    - Tom Occhino, Ben Alpert, Lee Byron, Christopher Chedeau, Sebastian Markbåge, Jing Chen, and Dan Schafer closed the conference with a Q&A session. + Tom Occhino, Sophie Alpert, Lee Byron, Christopher Chedeau, Sebastian Markbåge, Jing Chen, and Dan Schafer closed the conference with a Q&A session.

    @@ -819,175 +900,6 @@ Minified build for production: - - -

    - - React v0.13.0 Beta 1 - -

    - -

    - January 27, 2015 - by - - - Sebastian Markbåge - - - -

    - -
    - -
    -

    React 0.13 has a lot of nice features but there is one particular feature that I'm really excited about. I couldn't wait for React.js Conf to start tomorrow morning.

    - -

    Maybe you're like me and staying up late excited about the conference, or maybe you weren't one of the lucky ones to get a ticket. Either way I figured I'd give you all something to play with until then.

    - -

    We just published a beta version of React v0.13.0 to npm! You can install it with npm install react@0.13.0-beta.1. Since this is a pre-release, we don't have proper release notes ready.

    - -

    So what is that one feature I'm so excited about that I just couldn't wait to share?

    - -

    Plain JavaScript Classes!!

    - -

    JavaScript originally didn't have a built-in class system. Every popular framework built their own, and so did we. This means that you have a learn slightly different semantics for each framework.

    - -

    We figured that we're not in the business of designing a class system. We just want to use whatever is the idiomatic JavaScript way of creating classes.

    - -

    In React 0.13.0 you no longer need to use React.createClass to create React components. If you have a transpiler you can use ES6 classes today. You can use the transpiler we ship with react-tools by making use of the harmony option: jsx --harmony.

    - -

    ES6 Classes

    -
    class HelloMessage extends React.Component {
    -  render() {
    -    return <div>Hello {this.props.name}</div>;
    -  }
    -}
    -
    -React.render(<HelloMessage name="Sebastian" />, mountNode);
    -
    -

    The API is mostly what you would expect, with the exception of getInitialState. We figured that the idiomatic way to specify class state is to just use a simple instance property. Likewise getDefaultProps and propTypes are really just properties on the constructor.

    -
    export class Counter extends React.Component {
    -  constructor(props) {
    -    super(props);
    -    this.state = {count: props.initialCount};
    -  }
    -  tick() {
    -    this.setState({count: this.state.count + 1});
    -  }
    -  render() {
    -    return (
    -      <div onClick={this.tick.bind(this)}>
    -        Clicks: {this.state.count}
    -      </div>
    -    );
    -  }
    -}
    -Counter.propTypes = { initialCount: React.PropTypes.number };
    -Counter.defaultProps = { initialCount: 0 };
    -
    -

    ES7+ Property Initializers

    - -

    Wait, assigning to properties seems like a very imperative way of defining classes! You're right, however, we designed it this way because it's idiomatic. We fully expect a more declarative syntax for property initialization to arrive in future version of JavaScript. It might look something like this:

    -
    // Future Version
    -export class Counter extends React.Component {
    -  static propTypes = { initialCount: React.PropTypes.number };
    -  static defaultProps = { initialCount: 0 };
    -  state = { count: this.props.initialCount };
    -  tick() {
    -    this.setState({ count: this.state.count + 1 });
    -  }
    -  render() {
    -    return (
    -      <div onClick={this.tick.bind(this)}>
    -        Clicks: {this.state.count}
    -      </div>
    -    );
    -  }
    -}
    -
    -

    This was inspired by TypeScript's property initializers.

    - -

    Autobinding

    - -

    React.createClass has a built-in magic feature that bound all methods to this automatically for you. This can be a little confusing for JavaScript developers that are not used to this feature in other classes, or it can be confusing when they move from React to other classes.

    - -

    Therefore we decided not to have this built-in into React's class model. You can still explicitly prebind methods in your constructor if you want.

    -
    class Counter extends React.Component {
    -  constructor() {
    -    super();
    -    this.tick = this.tick.bind(this);
    -  }
    -  tick() {
    -    ...
    -  }
    -  ...
    -}
    -
    -

    However, when we have the future property initializers, there is a neat trick that you can use to accomplish this syntactically:

    -
    class Counter extends React.Component {
    -  tick = () => {
    -    ...
    -  }
    -  ...
    -}
    -
    -

    Mixins

    - -

    Unfortunately, we will not launch any mixin support for ES6 classes in React. That would defeat the purpose of only using idiomatic JavaScript concepts.

    - -

    There is no standard and universal way to define mixins in JavaScript. In fact, several features to support mixins were dropped from ES6 today. There are a lot of libraries with different semantics. We think that there should be one way of defining mixins that you can use for any JavaScript class. React just making another doesn't help that effort.

    - -

    Therefore, we will keep working with the larger JS community to create a standard for mixins. We will also start designing a new compositional API that will help make common tasks easier to do without mixins. E.g. first-class subscriptions to any kind of Flux store.

    - -

    Luckily, if you want to keep using mixins, you can just keep using React.createClass.

    - -
    -

    Note:

    - -

    The classic React.createClass style of creating classes will continue to work just fine.

    -
    - -

    Other Languages!

    - -

    Since these classes are just plain old JavaScript classes, you can use other languages that compile to JavaScript classes, such as TypeScript.

    - -

    You can also use CoffeeScript classes:

    -
    div = React.createFactory 'div'
    -
    -class Counter extends React.Component
    -  @propTypes = initialCount: React.PropTypes.number
    -  @defaultProps = initialCount: 0
    -
    -  constructor: (props) ->
    -    super props
    -    @state = count: props.initialCount
    -
    -  tick: =>
    -    @setState count: @state.count + 1
    -
    -  render: ->
    -    div onClick: @tick,
    -      'Clicks: '
    -      @state.count
    -
    -

    You can even use the old ES3 module pattern if you want:

    -
    function MyComponent(initialProps) {
    -  return {
    -    state: { value: initialProps.initialValue },
    -    render: function() {
    -      return <span className={this.state.value} />
    -    }
    -  };
    -}
    -
    -
    - - -
    diff --git a/blog/page12/index.html b/blog/page12/index.html index 1faf8339e0..e60d715f85 100644 --- a/blog/page12/index.html +++ b/blog/page12/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,175 @@
    +

    + + React v0.13.0 Beta 1 + +

    + +

    + January 27, 2015 + by + + + Sebastian Markbåge + + + +

    + +
    + +
    +

    React 0.13 has a lot of nice features but there is one particular feature that I'm really excited about. I couldn't wait for React.js Conf to start tomorrow morning.

    + +

    Maybe you're like me and staying up late excited about the conference, or maybe you weren't one of the lucky ones to get a ticket. Either way I figured I'd give you all something to play with until then.

    + +

    We just published a beta version of React v0.13.0 to npm! You can install it with npm install react@0.13.0-beta.1. Since this is a pre-release, we don't have proper release notes ready.

    + +

    So what is that one feature I'm so excited about that I just couldn't wait to share?

    + +

    Plain JavaScript Classes!!

    + +

    JavaScript originally didn't have a built-in class system. Every popular framework built their own, and so did we. This means that you have a learn slightly different semantics for each framework.

    + +

    We figured that we're not in the business of designing a class system. We just want to use whatever is the idiomatic JavaScript way of creating classes.

    + +

    In React 0.13.0 you no longer need to use React.createClass to create React components. If you have a transpiler you can use ES6 classes today. You can use the transpiler we ship with react-tools by making use of the harmony option: jsx --harmony.

    + +

    ES6 Classes

    +
    class HelloMessage extends React.Component {
    +  render() {
    +    return <div>Hello {this.props.name}</div>;
    +  }
    +}
    +
    +React.render(<HelloMessage name="Sebastian" />, mountNode);
    +
    +

    The API is mostly what you would expect, with the exception of getInitialState. We figured that the idiomatic way to specify class state is to just use a simple instance property. Likewise getDefaultProps and propTypes are really just properties on the constructor.

    +
    export class Counter extends React.Component {
    +  constructor(props) {
    +    super(props);
    +    this.state = {count: props.initialCount};
    +  }
    +  tick() {
    +    this.setState({count: this.state.count + 1});
    +  }
    +  render() {
    +    return (
    +      <div onClick={this.tick.bind(this)}>
    +        Clicks: {this.state.count}
    +      </div>
    +    );
    +  }
    +}
    +Counter.propTypes = { initialCount: React.PropTypes.number };
    +Counter.defaultProps = { initialCount: 0 };
    +
    +

    ES7+ Property Initializers

    + +

    Wait, assigning to properties seems like a very imperative way of defining classes! You're right, however, we designed it this way because it's idiomatic. We fully expect a more declarative syntax for property initialization to arrive in future version of JavaScript. It might look something like this:

    +
    // Future Version
    +export class Counter extends React.Component {
    +  static propTypes = { initialCount: React.PropTypes.number };
    +  static defaultProps = { initialCount: 0 };
    +  state = { count: this.props.initialCount };
    +  tick() {
    +    this.setState({ count: this.state.count + 1 });
    +  }
    +  render() {
    +    return (
    +      <div onClick={this.tick.bind(this)}>
    +        Clicks: {this.state.count}
    +      </div>
    +    );
    +  }
    +}
    +
    +

    This was inspired by TypeScript's property initializers.

    + +

    Autobinding

    + +

    React.createClass has a built-in magic feature that bound all methods to this automatically for you. This can be a little confusing for JavaScript developers that are not used to this feature in other classes, or it can be confusing when they move from React to other classes.

    + +

    Therefore we decided not to have this built-in into React's class model. You can still explicitly prebind methods in your constructor if you want.

    +
    class Counter extends React.Component {
    +  constructor() {
    +    super();
    +    this.tick = this.tick.bind(this);
    +  }
    +  tick() {
    +    ...
    +  }
    +  ...
    +}
    +
    +

    However, when we have the future property initializers, there is a neat trick that you can use to accomplish this syntactically:

    +
    class Counter extends React.Component {
    +  tick = () => {
    +    ...
    +  }
    +  ...
    +}
    +
    +

    Mixins

    + +

    Unfortunately, we will not launch any mixin support for ES6 classes in React. That would defeat the purpose of only using idiomatic JavaScript concepts.

    + +

    There is no standard and universal way to define mixins in JavaScript. In fact, several features to support mixins were dropped from ES6 today. There are a lot of libraries with different semantics. We think that there should be one way of defining mixins that you can use for any JavaScript class. React just making another doesn't help that effort.

    + +

    Therefore, we will keep working with the larger JS community to create a standard for mixins. We will also start designing a new compositional API that will help make common tasks easier to do without mixins. E.g. first-class subscriptions to any kind of Flux store.

    + +

    Luckily, if you want to keep using mixins, you can just keep using React.createClass.

    + +
    +

    Note:

    + +

    The classic React.createClass style of creating classes will continue to work just fine.

    +
    + +

    Other Languages!

    + +

    Since these classes are just plain old JavaScript classes, you can use other languages that compile to JavaScript classes, such as TypeScript.

    + +

    You can also use CoffeeScript classes:

    +
    div = React.createFactory 'div'
    +
    +class Counter extends React.Component
    +  @propTypes = initialCount: React.PropTypes.number
    +  @defaultProps = initialCount: 0
    +
    +  constructor: (props) ->
    +    super props
    +    @state = count: props.initialCount
    +
    +  tick: =>
    +    @setState count: @state.count + 1
    +
    +  render: ->
    +    div onClick: @tick,
    +      'Clicks: '
    +      @state.count
    +
    +

    You can even use the old ES3 module pattern if you want:

    +
    function MyComponent(initialProps) {
    +  return {
    +    state: { value: initialProps.initialValue },
    +    render: function() {
    +      return <span className={this.state.value} />
    +    }
    +  };
    +}
    +
    +
    + + + +
    + +
    + +

    React.js Conf Diversity Scholarship @@ -425,184 +595,6 @@ until the next conference. All the talks will be recorded and put online shortly -

    - -
    - - -

    - - React v0.12 - -

    - -

    - October 28, 2014 - by - - - Paul O’Shannessy - - - -

    - -
    - -
    -

    We're happy to announce the availability of React v0.12! After over a week of baking as the release candidate, we uncovered and fixed a few small issues. Thanks to all of you who upgraded and gave us feedback!

    - -

    We have talked a lot about some of the bigger changes in this release. We introduced new terminology and changed APIs to clean up and simplify some of the concepts of React. We also made several changes to JSX and deprecated a few functions. We won't go into depth about these changes again but we encourage you to read up on these changes in the linked posts. We'll summarize these changes and discuss some of the other changes and how they may impact you below. As always, a full changelog is also included below.

    - -

    The release is available for download:

    - - - -

    We've also published version 0.12.0 of the react and react-tools packages on npm and the react package on bower.

    - -

    New Terminology & Updated APIs

    - -

    v0.12 is bringing about some new terminology. We introduced this 2 weeks ago and we've also documented it in a new section of the documentation. As a part of this, we also corrected many of our top-level APIs to align with the terminology. Component has been removed from all of our React.render* methods. While at one point the argument you passed to these functions was called a Component, it no longer is. You are passing ReactElements. To align with render methods in your component classes, we decided to keep the top-level functions short and sweet. React.renderComponent is now React.render.

    - -

    We also corrected some other misnomers. React.isValidComponent actually determines if the argument is a ReactElement, so it has been renamed to React.isValidElement. In the same vein, React.PropTypes.component is now React.PropTypes.element and React.PropTypes.renderable is now React.PropTypes.node.

    - -

    The old methods will still work but will warn upon first use. They will be removed in v0.13.

    - -

    JSX Changes

    - -

    We talked more in depth about these before, so here are the highlights.

    - - - -

    DevTools Improvements, No More __internals

    - -

    For months we've gotten complaints about the React DevTools message. It shouldn't have logged the up-sell message when you were already using the DevTools. Unfortunately this was because the way we implemented these tools resulted in the DevTools knowing about React, but not the reverse. We finally gave this some attention and enabled React to know if the DevTools are installed. We released an update to the devtools several weeks ago making this possible. Extensions in Chrome should auto-update so you probably already have the update installed!

    - -

    As a result of this update, we no longer need to expose several internal modules to the world. If you were taking advantage of this implementation detail, your code will break. React.__internals is no more.

    - -

    License Change - BSD

    - -

    We updated the license on React to the BSD 3-Clause license with an explicit patent grant. Previously we used the Apache 2 license. These licenses are very similar and our extra patent grant is equivalent to the grant provided in the Apache license. You can still use React with the confidence that we have granted the use of any patents covering it. This brings us in line with the same licensing we use across the majority of our open source projects at Facebook.

    - -

    You can read the full text of the LICENSE and PATENTS files on GitHub.

    - -
    - -

    Changelog

    - -

    React Core

    - -

    Breaking Changes

    - - - -

    New Features

    - - - -

    Deprecations

    - - - -

    Bug Fixes

    - - - -

    React With Addons

    - -

    New Features

    - - - -

    Breaking Changes

    - - - -

    Bug Fixes

    - - - -

    JSX

    - -

    Breaking Changes

    - - - -

    New Features

    - - - -

    Bug Fixes

    - - - -
    - - -
    diff --git a/blog/page13/index.html b/blog/page13/index.html index 1509857935..0dbf62db4f 100644 --- a/blog/page13/index.html +++ b/blog/page13/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,184 @@
    +

    + + React v0.12 + +

    + +

    + October 28, 2014 + by + + + Paul O’Shannessy + + + +

    + +
    + +
    +

    We're happy to announce the availability of React v0.12! After over a week of baking as the release candidate, we uncovered and fixed a few small issues. Thanks to all of you who upgraded and gave us feedback!

    + +

    We have talked a lot about some of the bigger changes in this release. We introduced new terminology and changed APIs to clean up and simplify some of the concepts of React. We also made several changes to JSX and deprecated a few functions. We won't go into depth about these changes again but we encourage you to read up on these changes in the linked posts. We'll summarize these changes and discuss some of the other changes and how they may impact you below. As always, a full changelog is also included below.

    + +

    The release is available for download:

    + + + +

    We've also published version 0.12.0 of the react and react-tools packages on npm and the react package on bower.

    + +

    New Terminology & Updated APIs

    + +

    v0.12 is bringing about some new terminology. We introduced this 2 weeks ago and we've also documented it in a new section of the documentation. As a part of this, we also corrected many of our top-level APIs to align with the terminology. Component has been removed from all of our React.render* methods. While at one point the argument you passed to these functions was called a Component, it no longer is. You are passing ReactElements. To align with render methods in your component classes, we decided to keep the top-level functions short and sweet. React.renderComponent is now React.render.

    + +

    We also corrected some other misnomers. React.isValidComponent actually determines if the argument is a ReactElement, so it has been renamed to React.isValidElement. In the same vein, React.PropTypes.component is now React.PropTypes.element and React.PropTypes.renderable is now React.PropTypes.node.

    + +

    The old methods will still work but will warn upon first use. They will be removed in v0.13.

    + +

    JSX Changes

    + +

    We talked more in depth about these before, so here are the highlights.

    + + + +

    DevTools Improvements, No More __internals

    + +

    For months we've gotten complaints about the React DevTools message. It shouldn't have logged the up-sell message when you were already using the DevTools. Unfortunately this was because the way we implemented these tools resulted in the DevTools knowing about React, but not the reverse. We finally gave this some attention and enabled React to know if the DevTools are installed. We released an update to the devtools several weeks ago making this possible. Extensions in Chrome should auto-update so you probably already have the update installed!

    + +

    As a result of this update, we no longer need to expose several internal modules to the world. If you were taking advantage of this implementation detail, your code will break. React.__internals is no more.

    + +

    License Change - BSD

    + +

    We updated the license on React to the BSD 3-Clause license with an explicit patent grant. Previously we used the Apache 2 license. These licenses are very similar and our extra patent grant is equivalent to the grant provided in the Apache license. You can still use React with the confidence that we have granted the use of any patents covering it. This brings us in line with the same licensing we use across the majority of our open source projects at Facebook.

    + +

    You can read the full text of the LICENSE and PATENTS files on GitHub.

    + +
    + +

    Changelog

    + +

    React Core

    + +

    Breaking Changes

    + + + +

    New Features

    + + + +

    Deprecations

    + + + +

    Bug Fixes

    + + + +

    React With Addons

    + +

    New Features

    + + + +

    Breaking Changes

    + + + +

    Bug Fixes

    + + + +

    JSX

    + +

    Breaking Changes

    + + + +

    New Features

    + + + +

    Bug Fixes

    + + + +
    + + + +
    + +
    + +

    React.js Conf @@ -656,313 +835,6 @@ Minified build for production: - - -

    - - Testing Flux Applications - -

    - -

    - September 24, 2014 - by - - - Bill Fisher - - - -

    - -
    - -
    -

    A more up-to-date version of this post is available as part of the Flux documentation.

    - -

    Flux is the application architecture that Facebook uses to build web applications with React. It's based on a unidirectional data flow. In previous blog posts and documentation articles, we've shown the basic structure and data flow, more closely examined the dispatcher and action creators, and shown how to put it all together with a tutorial. Now let's look at how to do formal unit testing of Flux applications with Jest, Facebook's auto-mocking testing framework.

    - -

    Testing with Jest

    - -

    For a unit test to operate on a truly isolated unit of the application, we need to mock every module except the one we are testing. Jest makes the mocking of other parts of a Flux application trivial. To illustrate testing with Jest, we'll return to our example TodoMVC application.

    - -

    The first steps toward working with Jest are as follows:

    - -
      -
    1. Get the module dependencies for the application installed by running npm install.
    2. -
    3. Create a directory __tests__/ with a test file, in this case TodoStore-test.js
    4. -
    5. Run npm install jest-cli —save-dev
    6. -
    7. Add the following to your package.json
    8. -
    -
    {
    -  ...
    -  "scripts": {
    -    "test": "jest"
    -  }
    -  ...
    -}
    -
    -

    Now you're ready to run your tests from the command line with npm test.

    - -

    By default, all modules are mocked, so the only boilerplate we need in TodoStore-test.js is a declarative call to Jest's dontMock() method.

    -
    jest.dontMock('TodoStore');
    -
    -

    This tells Jest to let TodoStore be a real object with real, live methods. Jest will mock all other objects involved with the test.

    - -

    Testing Stores

    - -

    At Facebook, Flux stores often receive a great deal of formal unit test coverage, as this is where the application state and logic lives. Stores are arguably the most important place in a Flux application to provide coverage, but at first glance, it's not entirely obvious how to test them.

    - -

    By design, stores can't be modified from the outside. They have no setters. The only way new data can enter a store is through the callback it registers with the dispatcher.

    - -

    We therefore need to simulate the Flux data flow with this one weird trick.

    -
    var mockRegister = MyDispatcher.register;
    -var mockRegisterInfo = mockRegister.mock;
    -var callsToRegister = mockRegisterInfo.calls;
    -var firstCall = callsToRegister[0];
    -var firstArgument = firstCall[0];
    -var callback = firstArgument;
    -
    -

    We now have the store's registered callback, the sole mechanism by which data can enter the store.

    - -

    For folks new to Jest, or mocks in general, it might not be entirely obvious what is happening in that code block, so let's look at each part of it a bit more closely. We start out by looking at the register() method of our application's dispatcher — the method that the store uses to register its callback with the dispatcher. The dispatcher has been thoroughly mocked automatically by Jest, so we can get a reference to the mocked version of the register() method just as we would normally refer to that method in our production code. But we can get additional information about that method with the mock property of that method. We don't often think of methods having properties, but in Jest, this idea is vital. Every method of a mocked object has this property, and it allows us to examine how the method is being called during the test. A chronologically ordered list of calls to register() is available with the calls property of mock, and each of these calls has a list of the arguments that were used in each method call.

    - -

    So in this code, we are really saying, "Give me a reference to the first argument of the first call to MyDispatcher's register() method." That first argument is the store's callback, so now we have all we need to start testing. But first, we can save ourselves some semicolons and roll all of this into a single line:

    -
    callback = MyDispatcher.register.mock.calls[0][0];
    -
    -

    We can invoke that callback whenever we like, independent of our application's dispatcher or action creators. We will, in fact, fake the behavior of the dispatcher and action creators by invoking the callback with an action that we'll create directly in our test.

    -
    var payload = {
    -  source: 'VIEW_ACTION',
    -  action: {
    -    actionType: TodoConstants.TODO_CREATE,
    -    text: 'foo'
    -  }
    -};
    -callback(payload);
    -var all = TodoStore.getAll();
    -var keys = Object.keys(all);
    -expect(all[keys[0]].text).toEqual('foo');
    -
    -

    Putting it All Together

    - -

    The example Flux TodoMVC application has been updated with an example test for the TodoStore, but let's look at an abbreviated version of the entire test. The most important things to notice in this test are how we keep a reference to the store's registered callback in the closure of the test, and how we recreate the store before every test so that we clear the state of the store entirely.

    -
    jest.dontMock('../TodoStore');
    -jest.dontMock('react/lib/merge');
    -
    -describe('TodoStore', function() {
    -
    -  var TodoConstants = require('../../constants/TodoConstants');
    -
    -  // mock actions inside dispatch payloads
    -  var actionTodoCreate = {
    -    source: 'VIEW_ACTION',
    -    action: {
    -      actionType: TodoConstants.TODO_CREATE,
    -      text: 'foo'
    -    }
    -  };
    -  var actionTodoDestroy = {
    -    source: 'VIEW_ACTION',
    -    action: {
    -      actionType: TodoConstants.TODO_DESTROY,
    -      id: 'replace me in test'
    -    }
    -  };
    -
    -  var AppDispatcher;
    -  var TodoStore;
    -  var callback;
    -
    -  beforeEach(function() {
    -    AppDispatcher = require('../../dispatcher/AppDispatcher');
    -    TodoStore = require('../TodoStore');
    -    callback = AppDispatcher.register.mock.calls[0][0];
    -  });
    -
    -  it('registers a callback with the dispatcher', function() {
    -    expect(AppDispatcher.register.mock.calls.length).toBe(1);
    -  });
    -
    -  it('initializes with no to-do items', function() {
    -    var all = TodoStore.getAll();
    -    expect(all).toEqual({});
    -  });
    -
    -  it('creates a to-do item', function() {
    -    callback(actionTodoCreate);
    -    var all = TodoStore.getAll();
    -    var keys = Object.keys(all);
    -    expect(keys.length).toBe(1);
    -    expect(all[keys[0]].text).toEqual('foo');
    -  });
    -
    -  it('destroys a to-do item', function() {
    -    callback(actionTodoCreate);
    -    var all = TodoStore.getAll();
    -    var keys = Object.keys(all);
    -    expect(keys.length).toBe(1);
    -    actionTodoDestroy.action.id = keys[0];
    -    callback(actionTodoDestroy);
    -    expect(all[keys[0]]).toBeUndefined();
    -  });
    -
    -});
    -
    -

    You can take a look at all this code in the TodoStore's tests on GitHub as well.

    - -

    Mocking Data Derived from Other Stores

    - -

    Sometimes our stores rely on data from other stores. Because all of our modules are mocked, we'll need to simulate the data that comes from the other store. We can do this by retrieving the mock function and adding a custom return value to it.

    -
    var MyOtherStore = require('../MyOtherStore');
    -MyOtherStore.getState.mockReturnValue({
    -  '123': {
    -    id: '123',
    -    text: 'foo'
    -  },
    -  '456': {
    -    id: '456',
    -    text: 'bar'
    -  }
    -});
    -
    -

    Now we have a collection of objects that will come back from MyOtherStore whenever we call MyOtherStore.getState() in our tests. Any application state can be simulated with a combination of these custom return values and the previously shown technique of working with the store's registered callback.

    - -

    A brief example of this technique is up on GitHub within the Flux Chat example's UnreadThreadStore-test.js.

    - -

    For more information about the mock property of mocked methods or Jest's ability to provide custom mock values, see Jest's documentation on mock functions.

    - -

    Moving Logic from React to Stores

    - -

    What often starts as a little piece of seemingly benign logic in our React components often presents a problem while creating unit tests. We want to be able to write tests that read like a specification for our application's behavior, and when application logic slips into our view layer, this becomes more difficult.

    - -

    For example, when a user has marked each of their to-do items as complete, the TodoMVC specification dictates that we should also change the status of the "Mark all as complete" checkbox automatically. To create that logic, we might be tempted to write code like this in our MainSection's render() method:

    -
    var allTodos = this.props.allTodos;
    -var allChecked = true;
    -for (var id in allTodos) {
    -  if (!allTodos[id].complete) {
    -    allChecked = false;
    -    break;
    -  }
    -}
    -...
    -
    -return (
    -  <section id="main">
    -  <input
    -    id="toggle-all"
    -    type="checkbox"
    -    checked={allChecked ? 'checked' : ''}
    -  />
    -  ...
    -  </section>
    -);
    -
    -

    While this seems like an easy, normal thing to do, this is an example of application logic slipping into the views, and it can't be described in our spec-style TodoStore test. Let's take that logic and move it to the store. First, we'll create a public method on the store that will encapsulate that logic:

    -
    areAllComplete: function() {
    -  for (var id in _todos) {
    -    if (!_todos[id].complete) {
    -      return false;
    -    }
    -  }
    -  return true;
    -},
    -
    -

    Now we have the application logic where it belongs, and we can write the following test:

    -
    it('determines whether all to-do items are complete', function() {
    -  var i = 0;
    -  for (; i < 3; i++) {
    -    callback(mockTodoCreate);
    -  }
    -  expect(TodoStore.areAllComplete()).toBe(false);
    -
    -  var all = TodoStore.getAll();
    -  for (key in all) {
    -    callback({
    -      source: 'VIEW_ACTION',
    -      action: {
    -        actionType: TodoConstants.TODO_COMPLETE,
    -        id: key
    -      }
    -    });
    -  }
    -  expect(TodoStore.areAllComplete()).toBe(true);
    -
    -  callback({
    -    source: 'VIEW_ACTION',
    -    action: {
    -      actionType: TodoConstants.TODO_UNDO_COMPLETE,
    -      id: key
    -    }
    -  });
    -  expect(TodoStore.areAllComplete()).toBe(false);
    -});
    -
    -

    Finally, we revise our view layer. We'll call for that data in the controller-view, TodoApp.js, and pass it down to the MainSection component.

    -
    function getTodoState() {
    -  return {
    -    allTodos: TodoStore.getAll(),
    -    areAllComplete: TodoStore.areAllComplete()
    -  };
    -}
    -
    -var TodoApp = React.createClass({
    -...
    -
    -  /**
    -   * @return {object}
    -   */
    -  render: function() {
    -    return (
    -      ...
    -      <MainSection
    -        allTodos={this.state.allTodos}
    -        areAllComplete={this.state.areAllComplete}
    -      />
    -      ...
    -    );
    -  },
    -
    -  /**
    -   * Event handler for 'change' events coming from the TodoStore
    -   */
    -  _onChange: function() {
    -    this.setState(getTodoState());
    -  }
    -
    -});
    -
    -

    And then we'll utilize that property for the rendering of the checkbox.

    -
    render: function() {
    -  ...
    -
    -  return (
    -    <section id="main">
    -    <input
    -      id="toggle-all"
    -      type="checkbox"
    -      checked={this.props.areAllComplete ? 'checked' : ''}
    -    />
    -    ...
    -    </section>
    -  );
    -},
    -
    -

    To learn how to test React components themselves, check out the Jest tutorial for React and the ReactTestUtils documentation.

    - -

    Further Reading

    - - - -
    - - -

    diff --git a/blog/page14/index.html b/blog/page14/index.html index ffecb18df1..2d49ef2806 100644 --- a/blog/page14/index.html +++ b/blog/page14/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,313 @@
    +

    + + Testing Flux Applications + +

    + +

    + September 24, 2014 + by + + + Bill Fisher + + + +

    + +
    + +
    +

    A more up-to-date version of this post is available as part of the Flux documentation.

    + +

    Flux is the application architecture that Facebook uses to build web applications with React. It's based on a unidirectional data flow. In previous blog posts and documentation articles, we've shown the basic structure and data flow, more closely examined the dispatcher and action creators, and shown how to put it all together with a tutorial. Now let's look at how to do formal unit testing of Flux applications with Jest, Facebook's auto-mocking testing framework.

    + +

    Testing with Jest

    + +

    For a unit test to operate on a truly isolated unit of the application, we need to mock every module except the one we are testing. Jest makes the mocking of other parts of a Flux application trivial. To illustrate testing with Jest, we'll return to our example TodoMVC application.

    + +

    The first steps toward working with Jest are as follows:

    + +
      +
    1. Get the module dependencies for the application installed by running npm install.
    2. +
    3. Create a directory __tests__/ with a test file, in this case TodoStore-test.js
    4. +
    5. Run npm install jest-cli —save-dev
    6. +
    7. Add the following to your package.json
    8. +
    +
    {
    +  ...
    +  "scripts": {
    +    "test": "jest"
    +  }
    +  ...
    +}
    +
    +

    Now you're ready to run your tests from the command line with npm test.

    + +

    By default, all modules are mocked, so the only boilerplate we need in TodoStore-test.js is a declarative call to Jest's dontMock() method.

    +
    jest.dontMock('TodoStore');
    +
    +

    This tells Jest to let TodoStore be a real object with real, live methods. Jest will mock all other objects involved with the test.

    + +

    Testing Stores

    + +

    At Facebook, Flux stores often receive a great deal of formal unit test coverage, as this is where the application state and logic lives. Stores are arguably the most important place in a Flux application to provide coverage, but at first glance, it's not entirely obvious how to test them.

    + +

    By design, stores can't be modified from the outside. They have no setters. The only way new data can enter a store is through the callback it registers with the dispatcher.

    + +

    We therefore need to simulate the Flux data flow with this one weird trick.

    +
    var mockRegister = MyDispatcher.register;
    +var mockRegisterInfo = mockRegister.mock;
    +var callsToRegister = mockRegisterInfo.calls;
    +var firstCall = callsToRegister[0];
    +var firstArgument = firstCall[0];
    +var callback = firstArgument;
    +
    +

    We now have the store's registered callback, the sole mechanism by which data can enter the store.

    + +

    For folks new to Jest, or mocks in general, it might not be entirely obvious what is happening in that code block, so let's look at each part of it a bit more closely. We start out by looking at the register() method of our application's dispatcher — the method that the store uses to register its callback with the dispatcher. The dispatcher has been thoroughly mocked automatically by Jest, so we can get a reference to the mocked version of the register() method just as we would normally refer to that method in our production code. But we can get additional information about that method with the mock property of that method. We don't often think of methods having properties, but in Jest, this idea is vital. Every method of a mocked object has this property, and it allows us to examine how the method is being called during the test. A chronologically ordered list of calls to register() is available with the calls property of mock, and each of these calls has a list of the arguments that were used in each method call.

    + +

    So in this code, we are really saying, "Give me a reference to the first argument of the first call to MyDispatcher's register() method." That first argument is the store's callback, so now we have all we need to start testing. But first, we can save ourselves some semicolons and roll all of this into a single line:

    +
    callback = MyDispatcher.register.mock.calls[0][0];
    +
    +

    We can invoke that callback whenever we like, independent of our application's dispatcher or action creators. We will, in fact, fake the behavior of the dispatcher and action creators by invoking the callback with an action that we'll create directly in our test.

    +
    var payload = {
    +  source: 'VIEW_ACTION',
    +  action: {
    +    actionType: TodoConstants.TODO_CREATE,
    +    text: 'foo'
    +  }
    +};
    +callback(payload);
    +var all = TodoStore.getAll();
    +var keys = Object.keys(all);
    +expect(all[keys[0]].text).toEqual('foo');
    +
    +

    Putting it All Together

    + +

    The example Flux TodoMVC application has been updated with an example test for the TodoStore, but let's look at an abbreviated version of the entire test. The most important things to notice in this test are how we keep a reference to the store's registered callback in the closure of the test, and how we recreate the store before every test so that we clear the state of the store entirely.

    +
    jest.dontMock('../TodoStore');
    +jest.dontMock('react/lib/merge');
    +
    +describe('TodoStore', function() {
    +
    +  var TodoConstants = require('../../constants/TodoConstants');
    +
    +  // mock actions inside dispatch payloads
    +  var actionTodoCreate = {
    +    source: 'VIEW_ACTION',
    +    action: {
    +      actionType: TodoConstants.TODO_CREATE,
    +      text: 'foo'
    +    }
    +  };
    +  var actionTodoDestroy = {
    +    source: 'VIEW_ACTION',
    +    action: {
    +      actionType: TodoConstants.TODO_DESTROY,
    +      id: 'replace me in test'
    +    }
    +  };
    +
    +  var AppDispatcher;
    +  var TodoStore;
    +  var callback;
    +
    +  beforeEach(function() {
    +    AppDispatcher = require('../../dispatcher/AppDispatcher');
    +    TodoStore = require('../TodoStore');
    +    callback = AppDispatcher.register.mock.calls[0][0];
    +  });
    +
    +  it('registers a callback with the dispatcher', function() {
    +    expect(AppDispatcher.register.mock.calls.length).toBe(1);
    +  });
    +
    +  it('initializes with no to-do items', function() {
    +    var all = TodoStore.getAll();
    +    expect(all).toEqual({});
    +  });
    +
    +  it('creates a to-do item', function() {
    +    callback(actionTodoCreate);
    +    var all = TodoStore.getAll();
    +    var keys = Object.keys(all);
    +    expect(keys.length).toBe(1);
    +    expect(all[keys[0]].text).toEqual('foo');
    +  });
    +
    +  it('destroys a to-do item', function() {
    +    callback(actionTodoCreate);
    +    var all = TodoStore.getAll();
    +    var keys = Object.keys(all);
    +    expect(keys.length).toBe(1);
    +    actionTodoDestroy.action.id = keys[0];
    +    callback(actionTodoDestroy);
    +    expect(all[keys[0]]).toBeUndefined();
    +  });
    +
    +});
    +
    +

    You can take a look at all this code in the TodoStore's tests on GitHub as well.

    + +

    Mocking Data Derived from Other Stores

    + +

    Sometimes our stores rely on data from other stores. Because all of our modules are mocked, we'll need to simulate the data that comes from the other store. We can do this by retrieving the mock function and adding a custom return value to it.

    +
    var MyOtherStore = require('../MyOtherStore');
    +MyOtherStore.getState.mockReturnValue({
    +  '123': {
    +    id: '123',
    +    text: 'foo'
    +  },
    +  '456': {
    +    id: '456',
    +    text: 'bar'
    +  }
    +});
    +
    +

    Now we have a collection of objects that will come back from MyOtherStore whenever we call MyOtherStore.getState() in our tests. Any application state can be simulated with a combination of these custom return values and the previously shown technique of working with the store's registered callback.

    + +

    A brief example of this technique is up on GitHub within the Flux Chat example's UnreadThreadStore-test.js.

    + +

    For more information about the mock property of mocked methods or Jest's ability to provide custom mock values, see Jest's documentation on mock functions.

    + +

    Moving Logic from React to Stores

    + +

    What often starts as a little piece of seemingly benign logic in our React components often presents a problem while creating unit tests. We want to be able to write tests that read like a specification for our application's behavior, and when application logic slips into our view layer, this becomes more difficult.

    + +

    For example, when a user has marked each of their to-do items as complete, the TodoMVC specification dictates that we should also change the status of the "Mark all as complete" checkbox automatically. To create that logic, we might be tempted to write code like this in our MainSection's render() method:

    +
    var allTodos = this.props.allTodos;
    +var allChecked = true;
    +for (var id in allTodos) {
    +  if (!allTodos[id].complete) {
    +    allChecked = false;
    +    break;
    +  }
    +}
    +...
    +
    +return (
    +  <section id="main">
    +  <input
    +    id="toggle-all"
    +    type="checkbox"
    +    checked={allChecked ? 'checked' : ''}
    +  />
    +  ...
    +  </section>
    +);
    +
    +

    While this seems like an easy, normal thing to do, this is an example of application logic slipping into the views, and it can't be described in our spec-style TodoStore test. Let's take that logic and move it to the store. First, we'll create a public method on the store that will encapsulate that logic:

    +
    areAllComplete: function() {
    +  for (var id in _todos) {
    +    if (!_todos[id].complete) {
    +      return false;
    +    }
    +  }
    +  return true;
    +},
    +
    +

    Now we have the application logic where it belongs, and we can write the following test:

    +
    it('determines whether all to-do items are complete', function() {
    +  var i = 0;
    +  for (; i < 3; i++) {
    +    callback(mockTodoCreate);
    +  }
    +  expect(TodoStore.areAllComplete()).toBe(false);
    +
    +  var all = TodoStore.getAll();
    +  for (key in all) {
    +    callback({
    +      source: 'VIEW_ACTION',
    +      action: {
    +        actionType: TodoConstants.TODO_COMPLETE,
    +        id: key
    +      }
    +    });
    +  }
    +  expect(TodoStore.areAllComplete()).toBe(true);
    +
    +  callback({
    +    source: 'VIEW_ACTION',
    +    action: {
    +      actionType: TodoConstants.TODO_UNDO_COMPLETE,
    +      id: key
    +    }
    +  });
    +  expect(TodoStore.areAllComplete()).toBe(false);
    +});
    +
    +

    Finally, we revise our view layer. We'll call for that data in the controller-view, TodoApp.js, and pass it down to the MainSection component.

    +
    function getTodoState() {
    +  return {
    +    allTodos: TodoStore.getAll(),
    +    areAllComplete: TodoStore.areAllComplete()
    +  };
    +}
    +
    +var TodoApp = React.createClass({
    +...
    +
    +  /**
    +   * @return {object}
    +   */
    +  render: function() {
    +    return (
    +      ...
    +      <MainSection
    +        allTodos={this.state.allTodos}
    +        areAllComplete={this.state.areAllComplete}
    +      />
    +      ...
    +    );
    +  },
    +
    +  /**
    +   * Event handler for 'change' events coming from the TodoStore
    +   */
    +  _onChange: function() {
    +    this.setState(getTodoState());
    +  }
    +
    +});
    +
    +

    And then we'll utilize that property for the rendering of the checkbox.

    +
    render: function() {
    +  ...
    +
    +  return (
    +    <section id="main">
    +    <input
    +      id="toggle-all"
    +      type="checkbox"
    +      checked={this.props.areAllComplete ? 'checked' : ''}
    +    />
    +    ...
    +    </section>
    +  );
    +},
    +
    +

    To learn how to test React components themselves, check out the Jest tutorial for React and the ReactTestUtils documentation.

    + +

    Further Reading

    + + + +
    + + + +
    + +
    + +

    React v0.11.2 @@ -479,69 +787,6 @@ This is not the intended way to use React but can be useful as last resort if yo -

    - -
    - - -

    - - Flux: Actions and the Dispatcher - -

    - -

    - July 30, 2014 - by - - - Bill Fisher - - - -

    - -
    - -
    -

    Flux is the application architecture Facebook uses to build JavaScript applications. It's based on a unidirectional data flow. We've built everything from small widgets to huge applications with Flux, and it's handled everything we've thrown at it. Because we've found it to be a great way to structure our code, we're excited to share it with the open source community. Jing Chen presented Flux at the F8 conference, and since that time we've seen a lot of interest in it. We've also published an overview of Flux and a TodoMVC example, with an accompanying tutorial.

    - -

    Flux is more of a pattern than a full-blown framework, and you can start using it without a lot of new code beyond React. Up until recently, however, we haven't released one crucial piece of our Flux software: the dispatcher. But along with the creation of the new Flux code repository and Flux website, we've now open sourced the same dispatcher we use in our production applications.

    - -

    Where the Dispatcher Fits in the Flux Data Flow

    - -

    The dispatcher is a singleton, and operates as the central hub of data flow in a Flux application. It is essentially a registry of callbacks, and can invoke these callbacks in order. Each store registers a callback with the dispatcher. When new data comes into the dispatcher, it then uses these callbacks to propagate that data to all of the stores. The process of invoking the callbacks is initiated through the dispatch() method, which takes a data payload object as its sole argument.

    - -

    Actions and ActionCreators

    - -

    When new data enters the system, whether through a person interacting with the application or through a web api call, that data is packaged into an action — an object literal containing the new fields of data and a specific action type. We often create a library of helper methods called ActionCreators that not only create the action object, but also pass the action to the dispatcher.

    - -

    Different actions are identified by a type attribute. When all of the stores receive the action, they typically use this attribute to determine if and how they should respond to it. In a Flux application, both stores and views control themselves; they are not acted upon by external objects. Actions flow into the stores through the callbacks they define and register, not through setter methods.

    - -

    Letting the stores update themselves eliminates many entanglements typically found in MVC applications, where cascading updates between models can lead to unstable state and make accurate testing very difficult. The objects within a Flux application are highly decoupled, and adhere very strongly to the Law of Demeter, the principle that each object within a system should know as little as possible about the other objects in the system. This results in software that is more maintainable, adaptable, testable, and easier for new engineering team members to understand.

    - -

    - -

    Why We Need a Dispatcher

    - -

    As an application grows, dependencies across different stores are a near certainty. Store A will inevitably need Store B to update itself first, so that Store A can know how to update itself. We need the dispatcher to be able to invoke the callback for Store B, and finish that callback, before moving forward with Store A. To declaratively assert this dependency, a store needs to be able to say to the dispatcher, "I need to wait for Store B to finish processing this action." The dispatcher provides this functionality through its waitFor() method.

    - -

    The dispatch() method provides a simple, synchronous iteration through the callbacks, invoking each in turn. When waitFor() is encountered within one of the callbacks, execution of that callback stops and waitFor() provides us with a new iteration cycle over the dependencies. After the entire set of dependencies have been fulfilled, the original callback then continues to execute.

    - -

    Further, the waitFor() method may be used in different ways for different actions, within the same store's callback. In one case, Store A might need to wait for Store B. But in another case, it might need to wait for Store C. Using waitFor() within the code block that is specific to an action allows us to have fine-grained control of these dependencies.

    - -

    Problems arise, however, if we have circular dependencies. That is, if Store A needs to wait for Store B, and Store B needs to wait for Store A, we could wind up in an endless loop. The dispatcher now available in the Flux repo protects against this by throwing an informative error to alert the developer that this problem has occurred. The developer can then create a third store and resolve the circular dependency.

    - -

    Example Chat App

    - -

    Along with the same dispatcher that Facebook uses in its production applications, we've also published a new example chat app, slightly more complicated than the simplistic TodoMVC, so that engineers can better understand how Flux solves problems like dependencies between stores and calls to a web API.

    - -

    We're hopeful that the new Flux repository will grow with time to include additional tools, boilerplate code and further examples. And we hope that Flux will prove as useful to you as it has to us. Enjoy!

    - -
    - - -
    diff --git a/blog/page15/index.html b/blog/page15/index.html index 8758185d3a..6d3cec2b3d 100644 --- a/blog/page15/index.html +++ b/blog/page15/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,69 @@
    +

    + + Flux: Actions and the Dispatcher + +

    + +

    + July 30, 2014 + by + + + Bill Fisher + + + +

    + +
    + +
    +

    Flux is the application architecture Facebook uses to build JavaScript applications. It's based on a unidirectional data flow. We've built everything from small widgets to huge applications with Flux, and it's handled everything we've thrown at it. Because we've found it to be a great way to structure our code, we're excited to share it with the open source community. Jing Chen presented Flux at the F8 conference, and since that time we've seen a lot of interest in it. We've also published an overview of Flux and a TodoMVC example, with an accompanying tutorial.

    + +

    Flux is more of a pattern than a full-blown framework, and you can start using it without a lot of new code beyond React. Up until recently, however, we haven't released one crucial piece of our Flux software: the dispatcher. But along with the creation of the new Flux code repository and Flux website, we've now open sourced the same dispatcher we use in our production applications.

    + +

    Where the Dispatcher Fits in the Flux Data Flow

    + +

    The dispatcher is a singleton, and operates as the central hub of data flow in a Flux application. It is essentially a registry of callbacks, and can invoke these callbacks in order. Each store registers a callback with the dispatcher. When new data comes into the dispatcher, it then uses these callbacks to propagate that data to all of the stores. The process of invoking the callbacks is initiated through the dispatch() method, which takes a data payload object as its sole argument.

    + +

    Actions and ActionCreators

    + +

    When new data enters the system, whether through a person interacting with the application or through a web api call, that data is packaged into an action — an object literal containing the new fields of data and a specific action type. We often create a library of helper methods called ActionCreators that not only create the action object, but also pass the action to the dispatcher.

    + +

    Different actions are identified by a type attribute. When all of the stores receive the action, they typically use this attribute to determine if and how they should respond to it. In a Flux application, both stores and views control themselves; they are not acted upon by external objects. Actions flow into the stores through the callbacks they define and register, not through setter methods.

    + +

    Letting the stores update themselves eliminates many entanglements typically found in MVC applications, where cascading updates between models can lead to unstable state and make accurate testing very difficult. The objects within a Flux application are highly decoupled, and adhere very strongly to the Law of Demeter, the principle that each object within a system should know as little as possible about the other objects in the system. This results in software that is more maintainable, adaptable, testable, and easier for new engineering team members to understand.

    + +

    + +

    Why We Need a Dispatcher

    + +

    As an application grows, dependencies across different stores are a near certainty. Store A will inevitably need Store B to update itself first, so that Store A can know how to update itself. We need the dispatcher to be able to invoke the callback for Store B, and finish that callback, before moving forward with Store A. To declaratively assert this dependency, a store needs to be able to say to the dispatcher, "I need to wait for Store B to finish processing this action." The dispatcher provides this functionality through its waitFor() method.

    + +

    The dispatch() method provides a simple, synchronous iteration through the callbacks, invoking each in turn. When waitFor() is encountered within one of the callbacks, execution of that callback stops and waitFor() provides us with a new iteration cycle over the dependencies. After the entire set of dependencies have been fulfilled, the original callback then continues to execute.

    + +

    Further, the waitFor() method may be used in different ways for different actions, within the same store's callback. In one case, Store A might need to wait for Store B. But in another case, it might need to wait for Store C. Using waitFor() within the code block that is specific to an action allows us to have fine-grained control of these dependencies.

    + +

    Problems arise, however, if we have circular dependencies. That is, if Store A needs to wait for Store B, and Store B needs to wait for Store A, we could wind up in an endless loop. The dispatcher now available in the Flux repo protects against this by throwing an informative error to alert the developer that this problem has occurred. The developer can then create a third store and resolve the circular dependency.

    + +

    Example Chat App

    + +

    Along with the same dispatcher that Facebook uses in its production applications, we've also published a new example chat app, slightly more complicated than the simplistic TodoMVC, so that engineers can better understand how Flux solves problems like dependencies between stores and calls to a web API.

    + +

    We're hopeful that the new Flux repository will grow with time to include additional tools, boilerplate code and further examples. And we hope that Flux will prove as useful to you as it has to us. Enjoy!

    + +
    + + + +
    + +
    + +

    Community Round-up #20 @@ -688,95 +752,6 @@ Minified build for production: - - -

    - - Community Round-up #19 - -

    - -

    - June 27, 2014 - by - - - Cheng Lou - - - -

    - -
    - -
    -

    React Meetups!

    - -

    Ever wanted to find developers who also share the same interest in React than you? Recently, there has been a React Meetup in San Francisco (courtesy of Telmate), and one in London (courtesy of Stuart Harris, Cain Ullah and Zoe Merchant). These two events have been big successes; a second one in London is already planned.

    - -

    If you don't live near San Francisco or London, why not start one in your community?

    - -

    Complementary Tools

    - -

    In case you haven't seen it, we've consolidated the tooling solution around React on this wiki page. Some of the notable recent entries include:

    - - - -

    These are some of the links that often pop up on the #reactjs IRC channel. If you made something that you think deserves to be shown on the wiki, feel free to add it!

    - -

    React in Interesting Places

    - -

    The core concepts React themselves is something very valuable that the community is exploring and pushing further. A year ago, we wouldn't have imagined something like Bruce Hauman's Flappy Bird ClojureScript port, whose interactive programming has been made possible through React:

    - - - -

    And don't forget Pete Hunt's Wolfenstein 3D rendering engine in React (source code). While it's nearly a year old, it's still a nice demo.

    - -

    - -

    Give us a shoutout on IRC or React Google Groups if you've used React in some Interesting places.

    - -

    Even More People Using React

    - -

    Prismatic

    - -

    Prismatic recently shrank their codebase fivefold with the help of React and its popular ClojureScript wrapper, Om. They detailed their very positive experience here.

    - -
    -

    Finally, the state is normalized: each piece of information is represented in a single place. Since React ensures consistency between the DOM and the application data, the programmer can focus on ensuring that the state properly stays up to date in response to user input. If the application state is normalized, then this consistency is guaranteed by definition, completely avoiding the possibility of an entire class of common bugs.

    -
    - -

    Adobe Brackets

    - -

    Kevin Dangoor works on Brackets, the open-source code editor. After writing his first impression on React, he followed up with another insightful article on how to gradually make the code transition, how to preserve the editor's good parts, and how to tune Brackets' tooling around JSX.

    - -
    -

    We don’t need to switch to React everywhere, all at once. It’s not a framework that imposes anything on the application structure. [...] Easy, iterative adoption is definitely something in React’s favor for us.

    -
    - -

    Storehouse

    - -

    Storehouse (Apple Design Award 2014)'s web presence is build with React. Here's an example story. Congratulations on the award!

    - -

    Vim Awesome

    - -

    Vim Awesome, an open-source Vim plugins directory built on React, was just launched. Be sure to check out the source code if you're curious to see an example of how to build a small single-page React app.

    - -

    Random Tweets

    - - - -
    - - -

    diff --git a/blog/page16/index.html b/blog/page16/index.html index 1fecb57eb8..0904db6d86 100644 --- a/blog/page16/index.html +++ b/blog/page16/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,95 @@
    +

    + + Community Round-up #19 + +

    + +

    + June 27, 2014 + by + + + Cheng Lou + + + +

    + +
    + +
    +

    React Meetups!

    + +

    Ever wanted to find developers who also share the same interest in React than you? Recently, there has been a React Meetup in San Francisco (courtesy of Telmate), and one in London (courtesy of Stuart Harris, Cain Ullah and Zoe Merchant). These two events have been big successes; a second one in London is already planned.

    + +

    If you don't live near San Francisco or London, why not start one in your community?

    + +

    Complementary Tools

    + +

    In case you haven't seen it, we've consolidated the tooling solution around React on this wiki page. Some of the notable recent entries include:

    + + + +

    These are some of the links that often pop up on the #reactjs IRC channel. If you made something that you think deserves to be shown on the wiki, feel free to add it!

    + +

    React in Interesting Places

    + +

    The core concepts React themselves is something very valuable that the community is exploring and pushing further. A year ago, we wouldn't have imagined something like Bruce Hauman's Flappy Bird ClojureScript port, whose interactive programming has been made possible through React:

    + + + +

    And don't forget Pete Hunt's Wolfenstein 3D rendering engine in React (source code). While it's nearly a year old, it's still a nice demo.

    + +

    + +

    Give us a shoutout on IRC or React Google Groups if you've used React in some Interesting places.

    + +

    Even More People Using React

    + +

    Prismatic

    + +

    Prismatic recently shrank their codebase fivefold with the help of React and its popular ClojureScript wrapper, Om. They detailed their very positive experience here.

    + +
    +

    Finally, the state is normalized: each piece of information is represented in a single place. Since React ensures consistency between the DOM and the application data, the programmer can focus on ensuring that the state properly stays up to date in response to user input. If the application state is normalized, then this consistency is guaranteed by definition, completely avoiding the possibility of an entire class of common bugs.

    +
    + +

    Adobe Brackets

    + +

    Kevin Dangoor works on Brackets, the open-source code editor. After writing his first impression on React, he followed up with another insightful article on how to gradually make the code transition, how to preserve the editor's good parts, and how to tune Brackets' tooling around JSX.

    + +
    +

    We don’t need to switch to React everywhere, all at once. It’s not a framework that imposes anything on the application structure. [...] Easy, iterative adoption is definitely something in React’s favor for us.

    +
    + +

    Storehouse

    + +

    Storehouse (Apple Design Award 2014)'s web presence is build with React. Here's an example story. Congratulations on the award!

    + +

    Vim Awesome

    + +

    Vim Awesome, an open-source Vim plugins directory built on React, was just launched. Be sure to check out the source code if you're curious to see an example of how to build a small single-page React app.

    + +

    Random Tweets

    + + + +
    + + + +
    + +
    + +

    One Year of Open-Source React @@ -324,115 +414,6 @@ report bugs on GitHub.

    -

    - -
    - - -

    - - React v0.10 - -

    - -

    - March 21, 2014 - by - - - Paul O’Shannessy - - - -

    - -
    - -
    -

    Hot on the heels of the release candidate earlier this week, we're ready to call v0.10 done. The only major issue we discovered had to do with the react-tools package, which has been updated. We've copied over the changelog from the RC with some small clarifying changes.

    - -

    The release is available for download from the CDN:

    - - - -

    We've also published version 0.10.0 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 if you see anything awry.

    - -

    Clone On Mount

    - -

    The main purpose of this release is to provide a smooth upgrade path as we evolve some of the implementation of core. In v0.9 we started warning in cases where you called methods on unmounted components. This is part of an effort to enforce the idea that the return value of a component (React.DOM.div(), MyComponent()) is in fact not a reference to the component instance React uses in the virtual DOM. The return value is instead a light-weight object that React knows how to use. Since the return value currently is a reference to the same object React uses internally, we need to make this transition in stages as many people have come to depend on this implementation detail.

    - -

    In 0.10, we’re adding more warnings to catch a similar set of patterns. When a component is mounted we clone it and use that object for our internal representation. This allows us to capture calls you think you’re making to a mounted component. We’ll forward them on to the right object, but also warn you that this is breaking. See “Access to the Mounted Instance” on this page. Most of the time you can solve your pattern by using refs.

    - -

    Storing a reference to your top level component is a pattern touched upon on that page, but another examples that demonstrates what we see a lot of:

    -
    // This is a common pattern. However instance here really refers to a
    -// "descriptor", not necessarily the mounted instance.
    -var instance = <MyComponent/>;
    -React.renderComponent(instance);
    -// ...
    -instance.setProps(...);
    -
    -// The change here is very simple. The return value of renderComponent will be
    -// the mounted instance.
    -var instance = React.renderComponent(<MyComponent/>)
    -// ...
    -instance.setProps(...);
    -
    -

    These warnings and method forwarding are only enabled in the development build. The production builds continue to work as they did in v0.9. We strongly encourage you to use the development builds to catch these warnings and fix the call sites.

    - -

    The plan for v0.11 is that we will go fully to "descriptors". Method calls on the return value of MyComponent() will fail hard.

    - -

    Changelog

    - -

    React Core

    - -

    New Features

    - - - -

    Bug Fixes

    - - - -

    Addons

    - - - -

    react-tools

    - - - -
    - - -
    diff --git a/blog/page17/index.html b/blog/page17/index.html index 27dfd5bf12..d8fcaa106d 100644 --- a/blog/page17/index.html +++ b/blog/page17/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,115 @@
    +

    + + React v0.10 + +

    + +

    + March 21, 2014 + by + + + Paul O’Shannessy + + + +

    + +
    + +
    +

    Hot on the heels of the release candidate earlier this week, we're ready to call v0.10 done. The only major issue we discovered had to do with the react-tools package, which has been updated. We've copied over the changelog from the RC with some small clarifying changes.

    + +

    The release is available for download from the CDN:

    + + + +

    We've also published version 0.10.0 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 if you see anything awry.

    + +

    Clone On Mount

    + +

    The main purpose of this release is to provide a smooth upgrade path as we evolve some of the implementation of core. In v0.9 we started warning in cases where you called methods on unmounted components. This is part of an effort to enforce the idea that the return value of a component (React.DOM.div(), MyComponent()) is in fact not a reference to the component instance React uses in the virtual DOM. The return value is instead a light-weight object that React knows how to use. Since the return value currently is a reference to the same object React uses internally, we need to make this transition in stages as many people have come to depend on this implementation detail.

    + +

    In 0.10, we’re adding more warnings to catch a similar set of patterns. When a component is mounted we clone it and use that object for our internal representation. This allows us to capture calls you think you’re making to a mounted component. We’ll forward them on to the right object, but also warn you that this is breaking. See “Access to the Mounted Instance” on this page. Most of the time you can solve your pattern by using refs.

    + +

    Storing a reference to your top level component is a pattern touched upon on that page, but another examples that demonstrates what we see a lot of:

    +
    // This is a common pattern. However instance here really refers to a
    +// "descriptor", not necessarily the mounted instance.
    +var instance = <MyComponent/>;
    +React.renderComponent(instance);
    +// ...
    +instance.setProps(...);
    +
    +// The change here is very simple. The return value of renderComponent will be
    +// the mounted instance.
    +var instance = React.renderComponent(<MyComponent/>)
    +// ...
    +instance.setProps(...);
    +
    +

    These warnings and method forwarding are only enabled in the development build. The production builds continue to work as they did in v0.9. We strongly encourage you to use the development builds to catch these warnings and fix the call sites.

    + +

    The plan for v0.11 is that we will go fully to "descriptors". Method calls on the return value of MyComponent() will fail hard.

    + +

    Changelog

    + +

    React Core

    + +

    New Features

    + + + +

    Bug Fixes

    + + + +

    Addons

    + + + +

    react-tools

    + + + +
    + + + +
    + +
    + +

    React v0.10 RC @@ -475,7 +585,7 @@ Thomas Boyt (@thomasaboyt) wrote < by - Ben Alpert + Sophie Alpert @@ -634,169 +744,6 @@ Minified build for production: - - -

    - - React v0.9 RC - -

    - -

    - February 16, 2014 - by - - - 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:

    - - - -

    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 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:

    -
    <div>
    -  Monkeys:
    -  {listOfMonkeys} {submitButton}
    -</div>
    -
    -

    In v0.8 and below, it was transformed to the following:

    -
    React.DOM.div(null,
    -  " Monkeys: ",
    -  listOfMonkeys, submitButton
    -)
    -
    -

    In v0.9, it will be transformed to this JS instead:

    -
    React.DOM.div(null,
    -  "Monkeys:",
    -  listOfMonkeys, " ", submitButton
    -)
    -
    -

    We believe this new behavior is more helpful and eliminates 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 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
    • -
    - -
    - - -

    diff --git a/blog/page18/index.html b/blog/page18/index.html index e6b23aa172..21aa449621 100644 --- a/blog/page18/index.html +++ b/blog/page18/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,169 @@
    +

    + + React v0.9 RC + +

    + +

    + February 16, 2014 + by + + + Sophie 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:

    + + + +

    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 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:

    +
    <div>
    +  Monkeys:
    +  {listOfMonkeys} {submitButton}
    +</div>
    +
    +

    In v0.8 and below, it was transformed to the following:

    +
    React.DOM.div(null,
    +  " Monkeys: ",
    +  listOfMonkeys, submitButton
    +)
    +
    +

    In v0.9, it will be transformed to this JS instead:

    +
    React.DOM.div(null,
    +  "Monkeys:",
    +  listOfMonkeys, " ", submitButton
    +)
    +
    +

    We believe this new behavior is more helpful and eliminates 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 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

    + + + +

    New Features

    + + + +

    Bug Fixes

    + + + +

    React with Addons

    + + + +

    JSX Compiler and react-tools Package

    + + + +
    + + + +
    + +
    + +

    Community Round-up #16 @@ -517,140 +681,6 @@ rails s -

    - -
    - - -

    - - Community Round-up #13 - -

    - -

    - December 30, 2013 - by - - - 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 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.

    - -
    - -

    Try out the demos!

    - -

    Introduction to React

    - -

    Stoyan Stefanov talked at Joe Dev On Tech about React. He goes over all the features of the library and ends with a concrete example.

    - -
    - -

    JSX: E4X The Good Parts

    - -

    JSX is often compared to the now defunct E4X, Vjeux 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 ...

    -
    - -

    React + Socket.io

    - -

    Geert Pasteels 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!

    -
    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...

    - -

    cssobjectify

    - -

    Andrey Popp implemented a source transform that takes a CSS file and converts it to JSON. This integrates pretty nicely with React.

    -
    /* 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...

    - -

    ngReact

    - -

    David Chang working at HasOffer 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! -

    - -

    Read the full article...

    -
    - -

    vim-jsx

    - -

    Max Wang 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 syntax highlighting.

    - -

    Vim support for inline XML in JS is remarkably similar to the same for PHP.

    - -

    View on GitHub...

    -
    - -

    Random Tweet

    - -

    - -
    - - -
    diff --git a/blog/page19/index.html b/blog/page19/index.html index 362f84527a..895015be57 100644 --- a/blog/page19/index.html +++ b/blog/page19/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,140 @@
    +

    + + Community Round-up #13 + +

    + +

    + December 30, 2013 + by + + + 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 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.

    + +
    + +

    Try out the demos!

    + +

    Introduction to React

    + +

    Stoyan Stefanov talked at Joe Dev On Tech about React. He goes over all the features of the library and ends with a concrete example.

    + +
    + +

    JSX: E4X The Good Parts

    + +

    JSX is often compared to the now defunct E4X, Vjeux 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 ...

    +
    + +

    React + Socket.io

    + +

    Geert Pasteels 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!

    +
    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...

    + +

    cssobjectify

    + +

    Andrey Popp implemented a source transform that takes a CSS file and converts it to JSON. This integrates pretty nicely with React.

    +
    /* 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...

    + +

    ngReact

    + +

    David Chang working at HasOffer 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! +

    + +

    Read the full article...

    +
    + +

    vim-jsx

    + +

    Max Wang 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 syntax highlighting.

    + +

    Vim support for inline XML in JS is remarkably similar to the same for PHP.

    + +

    View on GitHub...

    +
    + +

    Random Tweet

    + +

    + +
    + + + +
    + +
    + +

    Community Round-up #12 @@ -459,160 +594,6 @@ Is this some sort of template language? Specifically no. This might have been th -

    - -
    - - -

    - - Community Round-up #10 - -

    - -

    - November 6, 2013 - by - - - 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 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

    -
    - -

    React: Rethinking best practices

    - -

    Pete Hunt's talk at JSConf EU 2013 is now available in video.

    - -
    - -

    Server-side React with PHP

    - -

    Stoyan Stefanov'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 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 ...

    - -

    Read part 2 ...

    - -

    Rendered markup on the server: -

    -
    - -

    TodoMVC Benchmarks

    - -

    Webkit has a TodoMVC Benchmark that compares different frameworks. They recently included React and here are the results (average of 10 runs in Chrome 30):

    - - - -

    Try it yourself!

    - -

    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:

    -
    /**
    - * 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 implemented a small game using React. The goal is to guess which filter has been used to create the Instagram photo. -

    - -

    React vs FruitMachine

    - -

    Andrew Betts, director of the Financial Times Labs, posted an article comparing 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...

    -
    - -

    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 implemented react-brunch, a JSX compilation step for Brunch.

    - -
    -

    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...

    -
    - -

    Random Tweet

    - -

    I'm going to start adding a tweet at the end of each round-up. We'll start with this one:

    - - - -
    - - -
    diff --git a/blog/page2/index.html b/blog/page2/index.html index 354c8969ae..aa192dedd2 100644 --- a/blog/page2/index.html +++ b/blog/page2/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,147 @@
    +

    + + What's New in Create React App + +

    + +

    + May 18, 2017 + by + + + Dan Abramov + + + +

    + +
    + +
    +

    Less than a year ago, we introduced Create React App as an officially supported way to create apps with zero configuration. The project has since enjoyed tremendous growth, with over 950 commits by more than 250 contributors.

    + +

    Today, we are excited to announce that many features that have been in the pipeline for the last few months are finally released.

    + +

    As usual with Create React App, you can enjoy these improvements in your existing non-ejected apps by updating a single dependency and following our migration instructions.

    + +

    Newly created apps will get these improvements automatically.

    + +

    webpack 2

    + +
    +

    This change was contributed by @Timer in #1291.

    +
    + +

    We have upgraded to webpack 2 which has been officially released a few months ago. It is a big upgrade with many bugfixes and general improvements. We have been testing it for a while, and now consider it stable enough to recommend it to everyone.

    + +

    While the Webpack configuration format has changed, Create React App users who didn't eject don't need to worry about it as we have updated the configuration on our side.

    + +

    If you had to eject your app for one reason or another, Webpack provides a configuration migration guide that you can follow to update your apps. Note that with each release of Create React App, we are working to support more use cases out of the box so that you don't have to eject in the future.

    + +

    The biggest notable webpack 2 feature is the ability to write and import ES6 modules directly without compiling them to CommonJS. This shouldn’t affect how you write code since you likely already use import and export statements, but it will help catch more mistakes like missing named exports at compile time:

    + +

    Export validation

    + +

    In the future, as the ecosystem around ES6 modules matures, you can expect more improvements to your app's bundle size thanks to tree shaking.

    + +

     Runtime Error Overlay

    + +
    +

    This change was contributed by @Timer and @nicinabox in #1101, @bvaughn in #2201.

    +
    + +

    Have you ever made a mistake in code and only realized it after the console is flooded with cryptic errors? Or worse, have you ever shipped an app with crashes in production because you accidentally missed an error in development?

    + +

    To address these issues, we are introducing an overlay that pops up whenever there is an uncaught error in your application. It only appears in development, and you can dismiss it by pressing Escape.

    + +

    A GIF is worth a thousand words:

    + +

    Runtime error overlay

    + +

    (Yes, it integrates with your editor!)

    + +

    In the future, we plan to teach the runtime error overlay to understand more about your React app. For example, after React 16 we plan to show React component stacks in addition to the JavaScript stacks when an error is thrown.

    + +

    Progressive Web Apps by Default

    + +
    +

    This change was contributed by @jeffposnick in #1728.

    +
    + +

    Newly created projects are built as Progressive Web Apps by default. This means that they employ service workers with an offline-first caching strategy to minimize the time it takes to serve the app to the users who visit it again. You can opt out of this behavior, but we recommend it both for new and existing apps, especially if you target mobile devices.

    + +

    Loading assets from service worker

    + +

    New apps automatically have these features, but you can easily convert an existing project to a Progressive Web App by following our migration guide.

    + +

    We will be adding more documentation on this topic in the coming weeks. Please feel free to ask any questions on the issue tracker!

    + +

    Jest 20

    + +
    +

    This change was contributed by @rogeliog in #1614 and @gaearon in #2171.

    +
    + +

    We are now using the latest version of Jest that includes numerous bugfixes and improvements. You can read more about the changes in Jest 19 and Jest 20 blog posts.

    + +

    Highlights include a new immersive watch mode, a better snapshot format, improvements to printing skipped tests, and new testing APIs.

    + +

    Immersive test watcher

    + +

    Additionally, Create React App now support configuring a few Jest options related to coverage reporting.

    + +

    Code Splitting with Dynamic import()

    + +
    +

    This change was contributed by @Timer in #1538 and @tharakawj in #1801.

    +
    + +

    It is important to keep the initial JavaScript payload of web apps down to the minimum, and load the rest of the code on demand. Although Create React App supported code splitting using require.ensure() since the first release, it used a webpack-specific syntax that did not work in Jest or other environments.

    + +

    In this release, we are adding support for the dynamic import() proposal which aligns with the future web standards. Unlike require.ensure(), it doesn't break Jest tests, and should eventually become a part of JavaScript. We encourage you to use import() to delay loading the code for non-critical component subtrees until you need to render them.

    + +

    Creating chunks with dynamic import

    + +

    Better Console Output

    + +
    +

    This change was contributed by @gaearon in #2120, #2125, and #2161.

    +
    + +

    We have improved the console output across the board.

    + +

    For example, when you start the development server, we now display the LAN address in additional to the localhost address so that you can quickly access the app from a mobile device on the same network:

    + +

    Better console output

    + +

    When lint errors are reported, we no longer show the warnings so that you can concentrate on more critical issues. Errors and warnings in the production build output are better formatted, and the build error overlay font size now matches the browser font size more closely.

    + +

    But Wait... There's More!

    + +

    You can only fit so much in a blog post, but there are other long-requested features in this release, such as environment-specific and local .env files, a lint rule against confusingly named globals, support for multiple proxies in development, a customizable browser launch script, and many bugfixes.

    + +

    You can read the full changelog and the migration guide in the v1.0.0 release notes.

    + +

    Acknowledgements

    + +

    This release is a result of months of work from many people in the React community. It is focused on improving both developer and end user experience, as we believe they are complementary and go hand in hand.

    + +

    We are grateful to everyone who has offered their contributions, whether in code, documentation, or by helping other people. We would like to specifically thank Joe Haddad for his invaluable help maintaining the project.

    + +

    We are excited to bring these improvements to everybody using Create React App, and we are looking forward to more of your feedback and contributions.

    + +
    + + + +
    + +
    + +

    React v15.5.0 @@ -843,7 +985,7 @@ I think we should just treat arrays of elements as a frag. This is useful for co

    We've also seen some great open-source projects spring up around Relay:

    @@ -916,189 +1058,6 @@ I think we should just treat arrays of elements as a frag. This is useful for co -

    - -
    - - -

    - - Create Apps with No Configuration - -

    - -

    - July 22, 2016 - by - - - Dan Abramov - - - -

    - -
    - -
    -

    Create React App is a new officially supported way to create single-page React applications. It offers a modern build setup with no configuration.

    - -

    Getting Started

    - -

    Installation

    - -

    First, install the global package:

    -
    npm install -g create-react-app
    -
    -

    Node.js 4.x or higher is required.

    - -

    Creating an App

    - -

    Now you can use it to create a new app:

    -
    create-react-app hello-world
    -
    -

    This will take a while as npm installs the transitive dependencies, but once it’s done, you will see a list of commands you can run in the created folder:

    - -

    created folder

    - -

    Starting the Server

    - -

    Run npm start to launch the development server. The browser will open automatically with the created app’s URL.

    - -

    compiled successfully

    - -

    Create React App uses both webpack and Babel under the hood. -The console output is tuned to be minimal to help you focus on the problems:

    - -

    failed to compile

    - -

    ESLint is also integrated so lint warnings are displayed right in the console:

    - -

    compiled with warnings

    - -

    We only picked a small subset of lint rules that often lead to bugs.

    - -

    Building for Production

    - -

    To build an optimized bundle, run npm run build:

    - -

    npm run build

    - -

    It is minified, correctly envified, and the assets include content hashes for caching.

    - -

    One Dependency

    - -

    Your package.json contains only a single build dependency and a few scripts:

    -
    {
    -  "name": "hello-world",
    -  "dependencies": {
    -    "react": "^15.2.1",
    -    "react-dom": "^15.2.1"
    -  },
    -  "devDependencies": {
    -    "react-scripts": "0.1.0"
    -  },
    -  "scripts": {
    -    "start": "react-scripts start",
    -    "build": "react-scripts build",
    -    "eject": "react-scripts eject"
    -  }
    -}
    -
    -

    We take care of updating Babel, ESLint, and webpack to stable compatible versions so you can update a single dependency to get them all.

    - -

    Zero Configuration

    - -

    It is worth repeating: there are no configuration files or complicated folder structures. The tool only generates the files you need to build your app.

    -
    hello-world/
    -  README.md
    -  index.html
    -  favicon.ico
    -  node_modules/
    -  package.json
    -  src/
    -    App.css
    -    App.js
    -    index.css
    -    index.js
    -    logo.svg
    -
    -

    All the build settings are preconfigured and can’t be changed. Some features, such as testing, are currently missing. This is an intentional limitation, and we recognize it might not work for everybody. And this brings us to the last point.

    - -

    No Lock-In

    - -

    We first saw this feature in Enclave, and we loved it. We talked to Ean, and he was excited to collaborate with us. He already sent a few pull requests!

    - -

    “Ejecting” lets you leave the comfort of Create React App setup at any time. You run a single command, and all the build dependencies, configs, and scripts are moved right into your project. At this point you can customize everything you want, but effectively you are forking our configuration and going your own way. If you’re experienced with build tooling and prefer to fine-tune everything to your taste, this lets you use Create React App as a boilerplate generator.

    - -

    We expect that at early stages, many people will “eject” for one reason or another, but as we learn from them, we will make the default setup more and more compelling while still providing no configuration.

    - -

    Try It Out!

    - -

    You can find Create React App with additional instructions on GitHub.

    - -

    This is an experiment, and only time will tell if it becomes a popular way of creating and building React apps, or fades into obscurity.

    - -

    We welcome you to participate in this experiment. Help us build the React tooling that more people can use. We are always open to feedback.

    - -

    The Backstory

    - -

    React was one of the first libraries to embrace transpiling JavaScript. As a result, even though you can learn React without any tooling, the React ecosystem has commonly become associated with an overwhelming explosion of tools.

    - -

    Eric Clemmons called this phenomenon the “JavaScript Fatigue”:

    - -
    -

    Ultimately, the problem is that by choosing React (and inherently JSX), you’ve unwittingly opted into a confusing nest of build tools, boilerplate, linters, & time-sinks to deal with before you ever get to create anything.

    -
    - -

    It is tempting to write code in ES2015 and JSX. It is sensible to use a bundler to keep the codebase modular, and a linter to catch the common mistakes. It is nice to have a development server with fast rebuilds, and a command to produce optimized bundles for production.

    - -

    Combining these tools requires some experience with each of them. Even so, it is far too easy to get dragged into fighting small incompatibilities, unsatisfied peerDependencies, and illegible configuration files.

    - -

    Many of those tools are plugin platforms and don’t directly acknowledge each other’s existence. They leave it up to the users to wire them together. The tools mature and change independently, and tutorials quickly get out of date.

    - - - - - -

    This doesn’t mean those tools aren’t great. To many of us, they have become indispensable, and we very much appreciate the effort of their maintainers. They already have too much on their plates to worry about the state of the React ecosystem.

    - -

    Still, we knew it was frustrating to spend days setting up a project when all you wanted was to learn React. We wanted to fix this.

    - -

    Could We Fix This?

    - -

    We found ourselves in an unusual dilemma.

    - -

    So far, our strategy has been to only release the code that we are using at Facebook. This helped us ensure that every project is battle-tested and has clearly defined scope and priorities.

    - -

    However, tooling at Facebook is different than at many smaller companies. Linting, transpilation, and packaging are all handled by powerful remote development servers, and product engineers don’t need to configure them. While we wish we could give a dedicated server to every user of React, even Facebook cannot scale that well!

    - -

    The React community is very important to us. We knew that we couldn’t fix the problem within the limits of our open source philosophy. This is why we decided to make an exception, and to ship something that we didn’t use ourselves, but that we thought would be useful to the community.

    - -

    The Quest for a React CLI

    - -

    Having just attended EmberCamp a week ago, I was excited about Ember CLI. Ember users have a great “getting started” experience thanks to a curated set of tools united under a single command-line interface. I have heard similar feedback about Elm Reactor.

    - -

    Providing a cohesive curated experience is valuable by itself, even if the user could in theory assemble those parts themselves. Kathy Sierra explains it best:

    - -
    -

    If your UX asks the user to make choices, for example, even if those choices are both clear and useful, the act of deciding is a cognitive drain. And not just while they’re deciding... even after we choose, an unconscious cognitive background thread is slowly consuming/leaking resources, “Was that the right choice?”

    -
    - -

    I never tried to write a command-line tool for React apps, and neither has Christopher. We were chatting on Messenger about this idea, and we decided to work together on it for a week as a hackathon project.

    - -

    We knew that such projects traditionally haven’t been very successful in the React ecosystem. Christopher told me that multiple “React CLI” projects have started and failed at Facebook. The community tools with similar goals also exist, but so far they have not yet gained enough traction.

    - -

    Still, we decided it was worth another shot. Christopher and I created a very rough proof of concept on the weekend, and Kevin soon joined us.

    - -

    We invited some of the community members to collaborate with us, and we have spent this week working on this tool. We hope that you’ll enjoy using it! Let us know what you think.

    - -

    We would like to express our gratitude to Max Stoiber, Jonny Buchanan, Ean Platter, Tyler McGinnis, Kent C. Dodds, and Eric Clemmons for their early feedback, ideas, and contributions.

    - -
    - - -
    diff --git a/blog/page20/index.html b/blog/page20/index.html index f6825eeae4..27e670566d 100644 --- a/blog/page20/index.html +++ b/blog/page20/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,160 @@
    +

    + + Community Round-up #10 + +

    + +

    + November 6, 2013 + by + + + 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 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

    +
    + +

    React: Rethinking best practices

    + +

    Pete Hunt's talk at JSConf EU 2013 is now available in video.

    + +
    + +

    Server-side React with PHP

    + +

    Stoyan Stefanov'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 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 ...

    + +

    Read part 2 ...

    + +

    Rendered markup on the server: +

    +
    + +

    TodoMVC Benchmarks

    + +

    Webkit has a TodoMVC Benchmark that compares different frameworks. They recently included React and here are the results (average of 10 runs in Chrome 30):

    + + + +

    Try it yourself!

    + +

    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:

    +
    /**
    + * 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 implemented a small game using React. The goal is to guess which filter has been used to create the Instagram photo. +

    + +

    React vs FruitMachine

    + +

    Andrew Betts, director of the Financial Times Labs, posted an article comparing 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...

    +
    + +

    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 implemented react-brunch, a JSX compilation step for Brunch.

    + +
    +

    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...

    +
    + +

    Random Tweet

    + +

    I'm going to start adding a tweet at the end of each round-up. We'll start with this one:

    + + + +
    + + + +
    + +
    + +

    React v0.5.1 @@ -126,7 +281,7 @@
    -

    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, Andrey Popp, and Laurence Rowe for their contributions!

    +

    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 Sophie Alpert, Andrey Popp, and Laurence Rowe for their contributions!

    Changelog

    @@ -391,7 +546,7 @@

    PETE: Exactly, exactly. In order to implement that, we communicate it as a fake DOM. What we'll do is rather than throw out the actual browser html and event handlers, we have an internal representation of what the page looks like and then we generate a brand new representation of what we want the page to look like. Then we perform this really, really fast diffing algorithm between those two page representations, DOM representations. Then React will compute the minimum set of DOM mutations it needs to make to bring the page up to date.

    -

    Then to finally get to answer your question, that set of DOM mutations then goes into a queue and we can plug in arbitrary flushing strategies for that. For example, when we originally launched React in open source, every setState would immediately trigger a flush to the DOM. That wasn't part of the contract of setState, but that was just our strategy and it worked pretty well. Then this totally awesome open source contributor Ben Alpert at Khan Academy built a new batching strategy which would basically queue up every single DOM update and state change that happened within an event tick and would execute them in bulk at the end of the event tick.

    +

    Then to finally get to answer your question, that set of DOM mutations then goes into a queue and we can plug in arbitrary flushing strategies for that. For example, when we originally launched React in open source, every setState would immediately trigger a flush to the DOM. That wasn't part of the contract of setState, but that was just our strategy and it worked pretty well. Then this totally awesome open source contributor Sophie Alpert at Khan Academy built a new batching strategy which would basically queue up every single DOM update and state change that happened within an event tick and would execute them in bulk at the end of the event tick.

    Read the full conversation ...

    @@ -426,8 +581,8 @@

    Markdown in React

    -

    Ben Alpert converted marked, a Markdown JavaScript implementation, in React: marked-react. Even without using JSX, the HTML generation is now a lot cleaner. It is also safer as forgetting a call to escape will not introduce an XSS vulnerability. -

    +

    Sophie Alpert converted marked, a Markdown JavaScript implementation, in React: marked-react. Even without using JSX, the HTML generation is now a lot cleaner. It is also safer as forgetting a call to escape will not introduce an XSS vulnerability. +

    Unite from BugBusters

    @@ -444,115 +599,6 @@ -
    - -
    - - -

    - - Community Round-up #7 - -

    - -

    - August 26, 2013 - by - - - Vjeux - - - -

    - -
    - -
    -

    It's been three months since we open sourced React and it is going well. Some stats so far:

    - - - -

    Wolfenstein Rendering Engine Ported to React

    - -

    Pete Hunt ported the render code of the web version of Wolfenstein 3D to React. Check out the demo and render.js file for the implementation. -

    - -

    React & Meteor

    - -

    Ben Newman made a 13-lines wrapper to use React and Meteor together. Meteor handles the real-time data synchronization between client and server. React provides the declarative way to write the interface and only updates the parts of the UI that changed.

    - -
    -

    This repository defines a Meteor package that automatically integrates the React rendering framework on both the client and the server, to complement or replace the default Handlebars templating system.

    - -

    The React core is officially agnostic about how you fetch and update your data, so it is far from obvious which approach is the best. This package provides one answer to that question (use Meteor!), and I hope you will find it a compelling combination.

    -
    var MyComponent = React.createClass({
    - mixins: [MeteorMixin],
    -
    - getMeteorState: function() {
    -   return { foo: Session.get('foo') };
    - },
    -
    - render: function() {
    -   return <div>{this.state.foo}</div>;
    - }
    -});
    -
    -

    Dependencies will be registered for any data accesses performed by getMeteorState so that the component can be automatically re-rendered whenever the data changes.

    - -

    Read more ...

    -
    - -

    React Page

    - -

    Jordan Walke implemented a complete React project creator called react-page. It supports both server-side and client-side rendering, source transform and packaging JSX files using CommonJS modules, and instant reload.

    - -
    -

    Easy Application Development with React JavaScript -

    - -

    Why Server Rendering?

    - -
      -
    • Faster initial page speed: - -
        -
      • Markup displayed before downloading large JavaScript.
      • -
      • Markup can be generated more quickly on a fast server than low power client devices.
      • -
    • -
    • Faster Development and Prototyping: - -
        -
      • Instantly refresh your app without waiting for any watch scripts or bundlers.
      • -
    • -
    • Easy deployment of static content pages/blogs: just archive using recursive wget.
    • -
    • SEO benefits of indexability and perf.
    • -
    - -

    How Does Server Rendering Work?

    - -
      -
    • react-page computes page markup on the server, sends it to the client so the user can see it quickly.
    • -
    • The corresponding JavaScript is then packaged and sent.
    • -
    • The browser runs that JavaScript, so that all of the event handlers, interactions and update code will run seamlessly on top of the server generated markup.
    • -
    • From the developer's (and the user's) perspective, it's just as if the rendering occurred on the client, only faster.
    • -
    - -

    Try it out ...

    -
    - -
    - - -
    diff --git a/blog/page21/index.html b/blog/page21/index.html index cc258ee5de..6fd636a87b 100644 --- a/blog/page21/index.html +++ b/blog/page21/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@

    @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,115 @@
    +

    + + Community Round-up #7 + +

    + +

    + August 26, 2013 + by + + + Vjeux + + + +

    + +
    + +
    +

    It's been three months since we open sourced React and it is going well. Some stats so far:

    + + + +

    Wolfenstein Rendering Engine Ported to React

    + +

    Pete Hunt ported the render code of the web version of Wolfenstein 3D to React. Check out the demo and render.js file for the implementation. +

    + +

    React & Meteor

    + +

    Ben Newman made a 13-lines wrapper to use React and Meteor together. Meteor handles the real-time data synchronization between client and server. React provides the declarative way to write the interface and only updates the parts of the UI that changed.

    + +
    +

    This repository defines a Meteor package that automatically integrates the React rendering framework on both the client and the server, to complement or replace the default Handlebars templating system.

    + +

    The React core is officially agnostic about how you fetch and update your data, so it is far from obvious which approach is the best. This package provides one answer to that question (use Meteor!), and I hope you will find it a compelling combination.

    +
    var MyComponent = React.createClass({
    + mixins: [MeteorMixin],
    +
    + getMeteorState: function() {
    +   return { foo: Session.get('foo') };
    + },
    +
    + render: function() {
    +   return <div>{this.state.foo}</div>;
    + }
    +});
    +
    +

    Dependencies will be registered for any data accesses performed by getMeteorState so that the component can be automatically re-rendered whenever the data changes.

    + +

    Read more ...

    +
    + +

    React Page

    + +

    Jordan Walke implemented a complete React project creator called react-page. It supports both server-side and client-side rendering, source transform and packaging JSX files using CommonJS modules, and instant reload.

    + +
    +

    Easy Application Development with React JavaScript +

    + +

    Why Server Rendering?

    + +
      +
    • Faster initial page speed: + +
        +
      • Markup displayed before downloading large JavaScript.
      • +
      • Markup can be generated more quickly on a fast server than low power client devices.
      • +
    • +
    • Faster Development and Prototyping: + +
        +
      • Instantly refresh your app without waiting for any watch scripts or bundlers.
      • +
    • +
    • Easy deployment of static content pages/blogs: just archive using recursive wget.
    • +
    • SEO benefits of indexability and perf.
    • +
    + +

    How Does Server Rendering Work?

    + +
      +
    • react-page computes page markup on the server, sends it to the client so the user can see it quickly.
    • +
    • The corresponding JavaScript is then packaged and sent.
    • +
    • The browser runs that JavaScript, so that all of the event handlers, interactions and update code will run seamlessly on top of the server generated markup.
    • +
    • From the developer's (and the user's) perspective, it's just as if the rendering occurred on the client, only faster.
    • +
    + +

    Try it out ...

    +
    + +
    + + + +
    + +
    + +

    Use React and JSX in Python Applications @@ -389,137 +499,6 @@ -

    - -
    - - -

    - - Community Round-up #5 - -

    - -

    - July 23, 2013 - by - - - Vjeux - - - -

    - -
    - -
    -

    We launched the React Facebook Page along with the React v0.4 launch. 700 people already liked it to get updated on the project :)

    - -

    Cross-browser onChange

    - -

    Ben Alpert from Khan Academy worked on a cross-browser implementation of onChange event that landed in v0.4. He wrote a blog post explaining the various browser quirks he had to deal with.

    - -
    -

    First off, what is the input event? If you have an <input> element and want to receive events whenever the value changes, the most obvious thing to do is to listen to the change event. Unfortunately, change fires only after the text field is defocused, rather than on each keystroke. The next obvious choice is the keyup event, which is triggered whenever a key is released. Unfortunately, keyup doesn't catch input that doesn't involve the keyboard (e.g., pasting from the clipboard using the mouse) and only fires once if a key is held down, rather than once per inserted character.

    - -

    Both keydown and keypress do fire repeatedly when a key is held down, but both fire immediately before the value changes, so to read the new value you have to defer the handler to the next event loop using setTimeout(fn, 0) or similar, which slows down your app. Of course, like keyup, neither keydown nor keypress fires for non-keyboard input events, and all three can fire in cases where the value doesn't change at all (such as when pressing the arrow keys).

    - -

    Read the full post...

    -
    - -

    React Samples

    - -

    Learning a new library is always easier when you have working examples you can play with. jwh put many of them on his react-samples GitHub repo.

    - -
    -

    Some simple examples with Facebook's React framework

    - - -
    - -

    React Chosen Wrapper

    - -

    Cheng Lou wrote a wrapper for the Chosen input library called react-chosen. It took just 25 lines to be able to use jQuery component as a React one.

    -
    React.renderComponent(
    -  <Chosen noResultsText="No result" value="Harvest" onChange={doSomething}>
    -    <option value="Facebook">Facebook</option>
    -    <option value="Harvest">Harvest</option>
    -  </Chosen>
    -, document.getElementById('example'));
    -
    -

    JSX and ES6 Template Strings

    - -

    Domenic Denicola wrote a slide deck about the great applications of ES6 features and one slide shows how we could use Template Strings to compile JSX at run-time without the need for a pre-processing phase.

    - -
    - -

    React Presentation

    - -

    Tom Occhino and Jordan Walke, React developers, did a presentation of React at Facebook Seattle's office. Check out the first 25 minutes for the presentation and the remaining 45 for a Q&A. I highly recommend you watching this video.

    - -
    - -

    Docs

    - -

    Pete Hunt rewrote the entirety of the docs for v0.4. The goal was to add more explanation about why we built React and what the best practices are.

    - -
    -

    Guides

    - - -
    - -
    - - -
    diff --git a/blog/page22/index.html b/blog/page22/index.html index aa586fb04f..da5d7a95bb 100644 --- a/blog/page22/index.html +++ b/blog/page22/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,137 @@
    +

    + + Community Round-up #5 + +

    + +

    + July 23, 2013 + by + + + Vjeux + + + +

    + +
    + +
    +

    We launched the React Facebook Page along with the React v0.4 launch. 700 people already liked it to get updated on the project :)

    + +

    Cross-browser onChange

    + +

    Sophie Alpert from Khan Academy worked on a cross-browser implementation of onChange event that landed in v0.4. She wrote a blog post explaining the various browser quirks she had to deal with.

    + +
    +

    First off, what is the input event? If you have an <input> element and want to receive events whenever the value changes, the most obvious thing to do is to listen to the change event. Unfortunately, change fires only after the text field is defocused, rather than on each keystroke. The next obvious choice is the keyup event, which is triggered whenever a key is released. Unfortunately, keyup doesn't catch input that doesn't involve the keyboard (e.g., pasting from the clipboard using the mouse) and only fires once if a key is held down, rather than once per inserted character.

    + +

    Both keydown and keypress do fire repeatedly when a key is held down, but both fire immediately before the value changes, so to read the new value you have to defer the handler to the next event loop using setTimeout(fn, 0) or similar, which slows down your app. Of course, like keyup, neither keydown nor keypress fires for non-keyboard input events, and all three can fire in cases where the value doesn't change at all (such as when pressing the arrow keys).

    + +

    Read the full post...

    +
    + +

    React Samples

    + +

    Learning a new library is always easier when you have working examples you can play with. jwh put many of them on his react-samples GitHub repo.

    + +
    +

    Some simple examples with Facebook's React framework

    + + +
    + +

    React Chosen Wrapper

    + +

    Cheng Lou wrote a wrapper for the Chosen input library called react-chosen. It took just 25 lines to be able to use jQuery component as a React one.

    +
    React.renderComponent(
    +  <Chosen noResultsText="No result" value="Harvest" onChange={doSomething}>
    +    <option value="Facebook">Facebook</option>
    +    <option value="Harvest">Harvest</option>
    +  </Chosen>
    +, document.getElementById('example'));
    +
    +

    JSX and ES6 Template Strings

    + +

    Domenic Denicola wrote a slide deck about the great applications of ES6 features and one slide shows how we could use Template Strings to compile JSX at run-time without the need for a pre-processing phase.

    + +
    + +

    React Presentation

    + +

    Tom Occhino and Jordan Walke, React developers, did a presentation of React at Facebook Seattle's office. Check out the first 25 minutes for the presentation and the remaining 45 for a Q&A. I highly recommend you watching this video.

    + +
    + +

    Docs

    + +

    Pete Hunt rewrote the entirety of the docs for v0.4. The goal was to add more explanation about why we built React and what the best practices are.

    + +
    +

    Guides

    + + +
    + +
    + + + +
    + +
    + +

    React v0.4.0 @@ -274,7 +406,7 @@ If you were using React without JSX previously, your code should still work.Khan Academy

    -

    Ben Kamens explains how Ben Alpert and Joel Burget are promoting React inside of Khan Academy. They now have three projects in the works using React.

    +

    Ben Kamens explains how Sophie Alpert and Joel Burget are promoting React inside of Khan Academy. They now have three projects in the works using React.

    Recently two Khan Academy devs dropped into our team chat and said they were gonna use React to write a new feature. They even hinted that we may want to adopt it product-wide.

    @@ -408,122 +540,6 @@ If you were using React without JSX previously, your code should still work. - -
    - - -

    - - Community Round-up #3 - -

    - -

    - June 27, 2013 - by - - - Vjeux - - - -

    - -
    - -
    -

    The highlight of this week is that an interaction-heavy app has been ported to React. React components are solving issues they had with nested views.

    - -

    Moving From Backbone To React

    - -

    Clay Allsopp successfully ported Propeller, a fairly big, interaction-heavy JavaScript app, to React.

    - -
    -

    Subviews involve a lot of easy-to-forget boilerplate that Backbone (by design) doesn't automate. Libraries like Backbone.Marionette offer more abstractions to make view nesting easier, but they're all limited by the fact that Backbone delegates how and went view-document attachment occurs to the application code.

    - -

    React, on the other hand, manages the DOM and only exposes real nodes at select points in its API. The "elements" you code in React are actually objects which wrap DOM nodes, not the actual objects which get inserted into the DOM. Internally, React converts those abstractions into actual DOMElements and fills out the document accordingly. [...]

    - -

    We moved about 20 different Backbone view classes to React over the past few weeks, including the live-preview pane that you see in our little iOS demo. Most importantly, it's allowed us to put energy into making each component work great on its own, instead of spending extra cycles to ensure they function in unison. For that reason, we think React is a more scalable way to build view-intensive apps than Backbone alone, and it doesn't require you to drop-everything-and-refactor like a move to Ember or Angular would demand.

    - -

    Read the full post...

    -
    - -

    Grunt Task for JSX

    - -

    Eric Clemmons wrote a task for Grunt that applies the JSX transformation to your JavaScript files. It also works with Browserify if you want all your files to be concatenated and minified together.

    - -
    -

    Grunt task for compiling Facebook React's .jsx templates into .js

    -
    grunt.initConfig({
    -  react: {
    -    app: {
    -      options: { extension: 'js' },
    -      files: { 'path/to/output/dir': 'path/to/jsx/templates/dir' }
    -
    -

    It also works great with grunt-browserify!

    -
    browserify: {
    -  options: {
    -    transform: [ require('grunt-react').browserify ]
    -  },
    -  app: {
    -    src: 'path/to/source/main.js',
    -    dest: 'path/to/target/output.js'
    -
    -

    Check out the project ...

    -
    - -

    Backbone/Handlebars Nested Views

    - -

    Joel Burget wrote a blog post talking about the way we would write React-like components in Backbone and Handlebars.

    - -
    -

    The problem here is that we're trying to maniplate a tree, but there's a textual layer we have to go through. Our views are represented as a tree - the subviews are children of CommentCollectionView - and they end up as part of a tree in the DOM. But there's a Handlebars layer in the middle (which deals in flat strings), so the hierarchy must be destructed and rebuilt when we render.

    - -

    What does it take to render a collection view? In the Backbone/Handlebars view of the world you have to render the template (with stubs), render each subview which replaces a stub, and keep a reference to each subview (or anything within the view that could change in the future).

    - -

    So while our view is conceptually hierarchical, due to the fact that it has to go through a flat textual representation, we need to do a lot of extra work to reassemble that structure after rendering.

    - -

    Read the full post...

    -
    - -

    JSRomandie Meetup

    - -

    Renault John Lecoultre from BugBuster did a React introduction talk at a JS meetup called JS Romandie last week.

    - - - -

    CoffeeScript integration

    - -

    Vjeux used the fact that JSX is just a syntactic sugar on-top of regular JS to rewrite the React front-page examples in CoffeeScript.

    - -
    -

    Multiple people asked what's the story about JSX and CoffeeScript. There is no JSX pre-processor for CoffeeScript and I'm not aware of anyone working on it. Fortunately, CoffeeScript is pretty expressive and we can play around the syntax to come up with something that is usable.

    -
    {div, h3, textarea} = React.DOM
    -(div {className: 'MarkdownEditor'}, [
    -  (h3 {}, 'Input'),
    -  (textarea {onKeyUp: @handleKeyUp, ref: 'textarea'},
    -    @state.value
    -  )
    -])
    -
    -

    Read the full post...

    -
    - -

    Tutorial in Plain JavaScript

    - -

    We've seen a lot of people comparing React with various frameworks. Ricardo Tomasi decided to re-implement the tutorial without any framework, just plain JavaScript.

    - -
    -

    Facebook & Instagram launched the React framework and an accompanying tutorial. Developer Vlad Yazhbin decided to rewrite that using AngularJS. The end result is pretty neat, but if you're like me you will not actually appreciate the HTML speaking for itself and doing all the hard work. So let's see what that looks like in plain javascript.

    - -

    Read the full post...

    -
    - -
    - - -
    diff --git a/blog/page23/index.html b/blog/page23/index.html index bd0b4e03e1..10d6abe0d0 100644 --- a/blog/page23/index.html +++ b/blog/page23/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@
    @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,122 @@
    +

    + + Community Round-up #3 + +

    + +

    + June 27, 2013 + by + + + Vjeux + + + +

    + +
    + +
    +

    The highlight of this week is that an interaction-heavy app has been ported to React. React components are solving issues they had with nested views.

    + +

    Moving From Backbone To React

    + +

    Clay Allsopp successfully ported Propeller, a fairly big, interaction-heavy JavaScript app, to React.

    + +
    +

    Subviews involve a lot of easy-to-forget boilerplate that Backbone (by design) doesn't automate. Libraries like Backbone.Marionette offer more abstractions to make view nesting easier, but they're all limited by the fact that Backbone delegates how and went view-document attachment occurs to the application code.

    + +

    React, on the other hand, manages the DOM and only exposes real nodes at select points in its API. The "elements" you code in React are actually objects which wrap DOM nodes, not the actual objects which get inserted into the DOM. Internally, React converts those abstractions into actual DOMElements and fills out the document accordingly. [...]

    + +

    We moved about 20 different Backbone view classes to React over the past few weeks, including the live-preview pane that you see in our little iOS demo. Most importantly, it's allowed us to put energy into making each component work great on its own, instead of spending extra cycles to ensure they function in unison. For that reason, we think React is a more scalable way to build view-intensive apps than Backbone alone, and it doesn't require you to drop-everything-and-refactor like a move to Ember or Angular would demand.

    + +

    Read the full post...

    +
    + +

    Grunt Task for JSX

    + +

    Eric Clemmons wrote a task for Grunt that applies the JSX transformation to your JavaScript files. It also works with Browserify if you want all your files to be concatenated and minified together.

    + +
    +

    Grunt task for compiling Facebook React's .jsx templates into .js

    +
    grunt.initConfig({
    +  react: {
    +    app: {
    +      options: { extension: 'js' },
    +      files: { 'path/to/output/dir': 'path/to/jsx/templates/dir' }
    +
    +

    It also works great with grunt-browserify!

    +
    browserify: {
    +  options: {
    +    transform: [ require('grunt-react').browserify ]
    +  },
    +  app: {
    +    src: 'path/to/source/main.js',
    +    dest: 'path/to/target/output.js'
    +
    +

    Check out the project ...

    +
    + +

    Backbone/Handlebars Nested Views

    + +

    Joel Burget wrote a blog post talking about the way we would write React-like components in Backbone and Handlebars.

    + +
    +

    The problem here is that we're trying to maniplate a tree, but there's a textual layer we have to go through. Our views are represented as a tree - the subviews are children of CommentCollectionView - and they end up as part of a tree in the DOM. But there's a Handlebars layer in the middle (which deals in flat strings), so the hierarchy must be destructed and rebuilt when we render.

    + +

    What does it take to render a collection view? In the Backbone/Handlebars view of the world you have to render the template (with stubs), render each subview which replaces a stub, and keep a reference to each subview (or anything within the view that could change in the future).

    + +

    So while our view is conceptually hierarchical, due to the fact that it has to go through a flat textual representation, we need to do a lot of extra work to reassemble that structure after rendering.

    + +

    Read the full post...

    +
    + +

    JSRomandie Meetup

    + +

    Renault John Lecoultre from BugBuster did a React introduction talk at a JS meetup called JS Romandie last week.

    + + + +

    CoffeeScript integration

    + +

    Vjeux used the fact that JSX is just a syntactic sugar on-top of regular JS to rewrite the React front-page examples in CoffeeScript.

    + +
    +

    Multiple people asked what's the story about JSX and CoffeeScript. There is no JSX pre-processor for CoffeeScript and I'm not aware of anyone working on it. Fortunately, CoffeeScript is pretty expressive and we can play around the syntax to come up with something that is usable.

    +
    {div, h3, textarea} = React.DOM
    +(div {className: 'MarkdownEditor'}, [
    +  (h3 {}, 'Input'),
    +  (textarea {onKeyUp: @handleKeyUp, ref: 'textarea'},
    +    @state.value
    +  )
    +])
    +
    +

    Read the full post...

    +
    + +

    Tutorial in Plain JavaScript

    + +

    We've seen a lot of people comparing React with various frameworks. Ricardo Tomasi decided to re-implement the tutorial without any framework, just plain JavaScript.

    + +
    +

    Facebook & Instagram launched the React framework and an accompanying tutorial. Developer Vlad Yazhbin decided to rewrite that using AngularJS. The end result is pretty neat, but if you're like me you will not actually appreciate the HTML speaking for itself and doing all the hard work. So let's see what that looks like in plain javascript.

    + +

    Read the full post...

    +
    + +
    + + + +
    + +
    + +

    React v0.3.3 @@ -288,15 +405,15 @@

    Khan Academy Question Editor

    -

    It looks like Ben Alpert is the first person outside of Facebook and Instagram to push React code to production. We are very grateful for his contributions in form of pull requests, bug reports and presence on IRC (#reactjs on Freenode). Ben wrote about his experience using React:

    +

    It looks like Sophie Alpert is the first person outside of Facebook and Instagram to push React code to production. We are very grateful for her contributions in form of pull requests, bug reports and presence on IRC (#reactjs on Freenode). Sophie wrote about her experience using React:

    I just rewrote a 2000-line project in React and have now made a handful of pull requests to React. Everything about React I've seen so far seems really well thought-out and I'm proud to be the first non-FB/IG production user of React.

    The project that I rewrote in React (and am continuing to improve) is the Khan Academy question editor which content creators can use to enter questions and hints that will be presented to students: -

    +

    -

    Read the full post...

    +

    Read the full post...

    Pimp my Backbone.View (by replacing it with React)

    @@ -458,41 +575,6 @@ but if you are interested in the nuts and bolts -
    - -
    - - -

    - - JSFiddle Integration - -

    - -

    - June 2, 2013 - by - - - Vjeux - - - -

    - -
    - -
    -

    JSFiddle just announced support for React. This is an exciting news as it makes collaboration on snippets of code a lot easier. You can play around this base React JSFiddle, fork it and share it! A fiddle without JSX is also available.

    - - - - - -
    - - -
    @@ -503,6 +585,10 @@ but if you are interested in the nuts and bolts + + diff --git a/blog/page24/index.html b/blog/page24/index.html new file mode 100644 index 0000000000..8cf9590c27 --- /dev/null +++ b/blog/page24/index.html @@ -0,0 +1,226 @@ + + + + + + + + + Blog - React + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    + + +
    + +
    + + +

    + + JSFiddle Integration + +

    + +

    + June 2, 2013 + by + + + Vjeux + + + +

    + +
    + +
    +

    JSFiddle just announced support for React. This is an exciting news as it makes collaboration on snippets of code a lot easier. You can play around this base React JSFiddle, fork it and share it! A fiddle without JSX is also available.

    + + + + + +
    + + + +
    + + + +
    +
    + + + + +
    + +
    + + + + diff --git a/blog/page3/index.html b/blog/page3/index.html index 9811d65df6..6d23e985a2 100644 --- a/blog/page3/index.html +++ b/blog/page3/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,189 @@
    +

    + + Create Apps with No Configuration + +

    + +

    + July 22, 2016 + by + + + Dan Abramov + + + +

    + +
    + +
    +

    Create React App is a new officially supported way to create single-page React applications. It offers a modern build setup with no configuration.

    + +

    Getting Started

    + +

    Installation

    + +

    First, install the global package:

    +
    npm install -g create-react-app
    +
    +

    Node.js 4.x or higher is required.

    + +

    Creating an App

    + +

    Now you can use it to create a new app:

    +
    create-react-app hello-world
    +
    +

    This will take a while as npm installs the transitive dependencies, but once it’s done, you will see a list of commands you can run in the created folder:

    + +

    created folder

    + +

    Starting the Server

    + +

    Run npm start to launch the development server. The browser will open automatically with the created app’s URL.

    + +

    compiled successfully

    + +

    Create React App uses both webpack and Babel under the hood. +The console output is tuned to be minimal to help you focus on the problems:

    + +

    failed to compile

    + +

    ESLint is also integrated so lint warnings are displayed right in the console:

    + +

    compiled with warnings

    + +

    We only picked a small subset of lint rules that often lead to bugs.

    + +

    Building for Production

    + +

    To build an optimized bundle, run npm run build:

    + +

    npm run build

    + +

    It is minified, correctly envified, and the assets include content hashes for caching.

    + +

    One Dependency

    + +

    Your package.json contains only a single build dependency and a few scripts:

    +
    {
    +  "name": "hello-world",
    +  "dependencies": {
    +    "react": "^15.2.1",
    +    "react-dom": "^15.2.1"
    +  },
    +  "devDependencies": {
    +    "react-scripts": "0.1.0"
    +  },
    +  "scripts": {
    +    "start": "react-scripts start",
    +    "build": "react-scripts build",
    +    "eject": "react-scripts eject"
    +  }
    +}
    +
    +

    We take care of updating Babel, ESLint, and webpack to stable compatible versions so you can update a single dependency to get them all.

    + +

    Zero Configuration

    + +

    It is worth repeating: there are no configuration files or complicated folder structures. The tool only generates the files you need to build your app.

    +
    hello-world/
    +  README.md
    +  index.html
    +  favicon.ico
    +  node_modules/
    +  package.json
    +  src/
    +    App.css
    +    App.js
    +    index.css
    +    index.js
    +    logo.svg
    +
    +

    All the build settings are preconfigured and can’t be changed. Some features, such as testing, are currently missing. This is an intentional limitation, and we recognize it might not work for everybody. And this brings us to the last point.

    + +

    No Lock-In

    + +

    We first saw this feature in Enclave, and we loved it. We talked to Ean, and he was excited to collaborate with us. He already sent a few pull requests!

    + +

    “Ejecting” lets you leave the comfort of Create React App setup at any time. You run a single command, and all the build dependencies, configs, and scripts are moved right into your project. At this point you can customize everything you want, but effectively you are forking our configuration and going your own way. If you’re experienced with build tooling and prefer to fine-tune everything to your taste, this lets you use Create React App as a boilerplate generator.

    + +

    We expect that at early stages, many people will “eject” for one reason or another, but as we learn from them, we will make the default setup more and more compelling while still providing no configuration.

    + +

    Try It Out!

    + +

    You can find Create React App with additional instructions on GitHub.

    + +

    This is an experiment, and only time will tell if it becomes a popular way of creating and building React apps, or fades into obscurity.

    + +

    We welcome you to participate in this experiment. Help us build the React tooling that more people can use. We are always open to feedback.

    + +

    The Backstory

    + +

    React was one of the first libraries to embrace transpiling JavaScript. As a result, even though you can learn React without any tooling, the React ecosystem has commonly become associated with an overwhelming explosion of tools.

    + +

    Eric Clemmons called this phenomenon the “JavaScript Fatigue”:

    + +
    +

    Ultimately, the problem is that by choosing React (and inherently JSX), you’ve unwittingly opted into a confusing nest of build tools, boilerplate, linters, & time-sinks to deal with before you ever get to create anything.

    +
    + +

    It is tempting to write code in ES2015 and JSX. It is sensible to use a bundler to keep the codebase modular, and a linter to catch the common mistakes. It is nice to have a development server with fast rebuilds, and a command to produce optimized bundles for production.

    + +

    Combining these tools requires some experience with each of them. Even so, it is far too easy to get dragged into fighting small incompatibilities, unsatisfied peerDependencies, and illegible configuration files.

    + +

    Many of those tools are plugin platforms and don’t directly acknowledge each other’s existence. They leave it up to the users to wire them together. The tools mature and change independently, and tutorials quickly get out of date.

    + + + + + +

    This doesn’t mean those tools aren’t great. To many of us, they have become indispensable, and we very much appreciate the effort of their maintainers. They already have too much on their plates to worry about the state of the React ecosystem.

    + +

    Still, we knew it was frustrating to spend days setting up a project when all you wanted was to learn React. We wanted to fix this.

    + +

    Could We Fix This?

    + +

    We found ourselves in an unusual dilemma.

    + +

    So far, our strategy has been to only release the code that we are using at Facebook. This helped us ensure that every project is battle-tested and has clearly defined scope and priorities.

    + +

    However, tooling at Facebook is different than at many smaller companies. Linting, transpilation, and packaging are all handled by powerful remote development servers, and product engineers don’t need to configure them. While we wish we could give a dedicated server to every user of React, even Facebook cannot scale that well!

    + +

    The React community is very important to us. We knew that we couldn’t fix the problem within the limits of our open source philosophy. This is why we decided to make an exception, and to ship something that we didn’t use ourselves, but that we thought would be useful to the community.

    + +

    The Quest for a React CLI

    + +

    Having just attended EmberCamp a week ago, I was excited about Ember CLI. Ember users have a great “getting started” experience thanks to a curated set of tools united under a single command-line interface. I have heard similar feedback about Elm Reactor.

    + +

    Providing a cohesive curated experience is valuable by itself, even if the user could in theory assemble those parts themselves. Kathy Sierra explains it best:

    + +
    +

    If your UX asks the user to make choices, for example, even if those choices are both clear and useful, the act of deciding is a cognitive drain. And not just while they’re deciding... even after we choose, an unconscious cognitive background thread is slowly consuming/leaking resources, “Was that the right choice?”

    +
    + +

    I never tried to write a command-line tool for React apps, and neither has Christopher. We were chatting on Messenger about this idea, and we decided to work together on it for a week as a hackathon project.

    + +

    We knew that such projects traditionally haven’t been very successful in the React ecosystem. Christopher told me that multiple “React CLI” projects have started and failed at Facebook. The community tools with similar goals also exist, but so far they have not yet gained enough traction.

    + +

    Still, we decided it was worth another shot. Christopher and I created a very rough proof of concept on the weekend, and Kevin soon joined us.

    + +

    We invited some of the community members to collaborate with us, and we have spent this week working on this tool. We hope that you’ll enjoy using it! Let us know what you think.

    + +

    We would like to express our gratitude to Max Stoiber, Jonny Buchanan, Ean Platter, Tyler McGinnis, Kent C. Dodds, and Eric Clemmons for their early feedback, ideas, and contributions.

    + +
    + + + +
    + +
    + +

    Mixins Considered Harmful @@ -727,7 +911,7 @@

    Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.

    -

    In order to make debugging in production easier, we're introducing an Error Code System in 15.2.0. We developed a gulp script that collects all of our invariant error messages and folds them to a JSON file, and at build-time Babel uses the JSON to rewrite our invariant calls in production to reference the corresponding error IDs. Now when things go wrong in production, the error that React throws will contain a URL with an error ID and relevant information. The URL will point you to a page in our documentation where the original error message gets reassembled.

    +

    In order to make debugging in production easier, we're introducing an Error Code System in 15.2.0. We developed a gulp script that collects all of our invariant error messages and folds them to a JSON file, and at build-time Babel uses the JSON to rewrite our invariant calls in production to reference the corresponding error IDs. Now when things go wrong in production, the error that React throws will contain a URL with an error ID and relevant information. The URL will point you to a page in our documentation where the original error message gets reassembled.

    While we hope you don't see errors often, you can see how it works here. This is what the same error from above will look like:

    @@ -801,7 +985,7 @@ Minified build for production: h

    @@ -892,7 +1076,7 @@ Minified build for production: h

    Note: data-reactid is still present for server-rendered content, however it is much smaller than before and is simply an auto-incrementing counter.

    -

    @spicyj in #5205

    +

    @sophiebits in #5205

  • No more extra <span>s

    Another big change with our DOM interaction is how we render text blocks. Previously you may have noticed that React rendered a lot of extra <span>s. For example, in our most basic example on the home page we render <div>Hello {this.props.name}</div>, resulting in markup that contained 2 <span>s. Now we’ll render plain text nodes interspersed with comment nodes that are used for demarcation. This gives us the same ability to update individual pieces of text, without creating extra nested nodes. Very few people have depended on the actual markup generated here so it’s likely you are not impacted. However if you were targeting these <span>s in your CSS, you will need to adjust accordingly. You can always render them explicitly in your components.

    @@ -902,7 +1086,7 @@ Minified build for production: h

    We’ve also made use of these comment nodes to change what null renders to. Rendering to null was a feature we added in React 0.11 and was implemented by rendering <noscript> elements. By rendering to comment nodes now, there’s a chance some of your CSS will be targeting the wrong thing, specifically if you are making use of :nth-child selectors. React’s use of the <noscript> tag has always been considered an implementation detail of how React targets the DOM. We believe they are safe changes to make without going through a release with warnings detailing the subtle differences as they are details that should not be depended upon. Additionally, we have seen that these changes have improved React performance for many typical applications.

    -

    @spicyj in #5451

  • +

    @sophiebits in #5451

  • Functional components can now return null too

    We added support for defining stateless components as functions in React 0.14. However, React 0.14 still allowed you to define a class component without extending React.Component or using React.createClass(), so we couldn’t reliably tell if your component is a function or a class, and did not allow returning null from it. This issue is solved in React 15, and you can now return null from any component, whether it is a class or a function.

    @@ -970,7 +1154,7 @@ Minified build for production: h @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,68 @@
    +

    + + React v0.14.8 + +

    + +

    + March 29, 2016 + by + + + Dan Abramov + + + +

    + +
    + +
    +

    We have already released two release candidates for React 15, and the final version is coming soon.

    + +

    However Ian Christian Myers discovered a memory leak related to server rendering in React 0.14 and contributed a fix. While this memory leak has already been fixed in a different way in the React 15 release candidates, we decided to cut another 0.14 release that contains just this fix.

    + +

    The release is now available for download:

    + + + +

    We've also published version 0.14.8 of the react, react-dom, and addons packages on npm and the react package on bower.

    + +
    + +

    Changelog

    + +

    React

    + +
      +
    • Fixed memory leak when rendering on the server
    • +
    + +
    + + + +
    + +
    + +

    React v15.0 Release Candidate 2 @@ -390,7 +453,7 @@ Minified build for production: Ben Alpert + Sophie Alpert @@ -409,86 +472,6 @@ Minified build for production: - - -

    - - (A => B) !=> (B => A) - -

    - -

    - January 8, 2016 - by - - - Jim Sproch - - - -

    - -
    - -
    -

    The documentation for componentWillReceiveProps states that componentWillReceiveProps will be invoked when the props change as the result of a rerender. Some people assume this means "if componentWillReceiveProps is called, then the props must have changed", but that conclusion is logically incorrect.

    - -

    The guiding principle is one of my favorites from formal logic/mathematics:

    - -
    -

    A implies B does not imply B implies A

    -
    - -

    Example: "If I eat moldy food, then I will get sick" does not imply "if I am sick, then I must have eaten moldy food". There are many other reasons I could be feeling sick. For instance, maybe the flu is circulating around the office. Similarly, there are many reasons that componentWillReceiveProps might get called, even if the props didn’t change.

    - -

    If you don’t believe me, call ReactDOM.render() three times with the exact same props, and try to predict the number of times componentWillReceiveProps will get called:

    -
    class Component extends React.Component {
    -  componentWillReceiveProps(nextProps) {
    -    console.log('componentWillReceiveProps', nextProps.data.bar);
    -  }
    -  render() {
    -    return <div>Bar {this.props.data.bar}!</div>;
    -  }
    -}
    -
    -var container = document.getElementById('container');
    -
    -var mydata = {bar: 'drinks'};
    -ReactDOM.render(<Component data={mydata} />, container);
    -ReactDOM.render(<Component data={mydata} />, container);
    -ReactDOM.render(<Component data={mydata} />, container);
    -
    -

    In this case, the answer is "2". React calls componentWillReceiveProps twice (once for each of the two updates). Both times, the value of "drinks" is printed (ie. the props didn’t change).

    - -

    To understand why, we need to think about what could have happened. The data could have changed between the initial render and the two subsequent updates, if the code had performed a mutation like this:

    -
    var mydata = {bar: 'drinks'};
    -ReactDOM.render(<Component data={mydata} />, container);
    -mydata.bar = 'food'
    -ReactDOM.render(<Component data={mydata} />, container);
    -mydata.bar = 'noise'
    -ReactDOM.render(<Component data={mydata} />, container);
    -
    -

    React has no way of knowing that the data didn’t change. Therefore, React needs to call componentWillReceiveProps, because the component needs to be notified of the new props (even if the new props happen to be the same as the old props).

    - -

    You might think that React could just use smarter checks for equality, but there are some issues with this idea:

    - -
      -
    • The old mydata and the new mydata are actually the same physical object (only the object’s internal value changed). Since the references are triple-equals-equal, doing an equality check doesn’t tell us if the value has changed. The only possible solution would be to have created a deep copy of the data, and then later do a deep comparison - but this can be prohibitively expensive for large data structures (especially ones with cycles).
    • -
    • The mydata object might contain references to functions which have captured variables within closures. There is no way for React to peek into these closures, and thus no way for React to copy them and/or verify equality.
    • -
    • The mydata object might contain references to objects which are re-instantiated during the parent's render (ie. not triple-equals-equal) but are conceptually equal (ie. same keys and same values). A deep-compare (expensive) could detect this, except that functions present a problem again because there is no reliable way to compare two functions to see if they are semantically equivalent.
    • -
    - -

    Given the language constraints, it is sometimes impossible for us to achieve meaningful equality semantics. In such cases, React will call componentWillReceiveProps (even though the props might not have changed) so the component has an opportunity to examine the new props and act accordingly.

    - -

    As a result, your implementation of componentWillReceiveProps MUST NOT assume that your props have changed. If you want an operation (such as a network request) to occur only when props have changed, your componentWillReceiveProps code needs to check to see if the props actually changed.

    - -
    - - -

    diff --git a/blog/page5/index.html b/blog/page5/index.html index b76706629e..aa29f104a6 100644 --- a/blog/page5/index.html +++ b/blog/page5/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,86 @@
    +

    + + (A => B) !=> (B => A) + +

    + +

    + January 8, 2016 + by + + + Jim Sproch + + + +

    + +
    + +
    +

    The documentation for componentWillReceiveProps states that componentWillReceiveProps will be invoked when the props change as the result of a rerender. Some people assume this means "if componentWillReceiveProps is called, then the props must have changed", but that conclusion is logically incorrect.

    + +

    The guiding principle is one of my favorites from formal logic/mathematics:

    + +
    +

    A implies B does not imply B implies A

    +
    + +

    Example: "If I eat moldy food, then I will get sick" does not imply "if I am sick, then I must have eaten moldy food". There are many other reasons I could be feeling sick. For instance, maybe the flu is circulating around the office. Similarly, there are many reasons that componentWillReceiveProps might get called, even if the props didn’t change.

    + +

    If you don’t believe me, call ReactDOM.render() three times with the exact same props, and try to predict the number of times componentWillReceiveProps will get called:

    +
    class Component extends React.Component {
    +  componentWillReceiveProps(nextProps) {
    +    console.log('componentWillReceiveProps', nextProps.data.bar);
    +  }
    +  render() {
    +    return <div>Bar {this.props.data.bar}!</div>;
    +  }
    +}
    +
    +var container = document.getElementById('container');
    +
    +var mydata = {bar: 'drinks'};
    +ReactDOM.render(<Component data={mydata} />, container);
    +ReactDOM.render(<Component data={mydata} />, container);
    +ReactDOM.render(<Component data={mydata} />, container);
    +
    +

    In this case, the answer is "2". React calls componentWillReceiveProps twice (once for each of the two updates). Both times, the value of "drinks" is printed (ie. the props didn’t change).

    + +

    To understand why, we need to think about what could have happened. The data could have changed between the initial render and the two subsequent updates, if the code had performed a mutation like this:

    +
    var mydata = {bar: 'drinks'};
    +ReactDOM.render(<Component data={mydata} />, container);
    +mydata.bar = 'food'
    +ReactDOM.render(<Component data={mydata} />, container);
    +mydata.bar = 'noise'
    +ReactDOM.render(<Component data={mydata} />, container);
    +
    +

    React has no way of knowing that the data didn’t change. Therefore, React needs to call componentWillReceiveProps, because the component needs to be notified of the new props (even if the new props happen to be the same as the old props).

    + +

    You might think that React could just use smarter checks for equality, but there are some issues with this idea:

    + +
      +
    • The old mydata and the new mydata are actually the same physical object (only the object’s internal value changed). Since the references are triple-equals-equal, doing an equality check doesn’t tell us if the value has changed. The only possible solution would be to have created a deep copy of the data, and then later do a deep comparison - but this can be prohibitively expensive for large data structures (especially ones with cycles).
    • +
    • The mydata object might contain references to functions which have captured variables within closures. There is no way for React to peek into these closures, and thus no way for React to copy them and/or verify equality.
    • +
    • The mydata object might contain references to objects which are re-instantiated during the parent's render (ie. not triple-equals-equal) but are conceptually equal (ie. same keys and same values). A deep-compare (expensive) could detect this, except that functions present a problem again because there is no reliable way to compare two functions to see if they are semantically equivalent.
    • +
    + +

    Given the language constraints, it is sometimes impossible for us to achieve meaningful equality semantics. In such cases, React will call componentWillReceiveProps (even though the props might not have changed) so the component has an opportunity to examine the new props and act accordingly.

    + +

    As a result, your implementation of componentWillReceiveProps MUST NOT assume that your props have changed. If you want an operation (such as a network request) to occur only when props have changed, your componentWillReceiveProps code needs to check to see if the props actually changed.

    + +
    + + + +
    + +
    + +

    React v0.14.4 @@ -117,7 +198,7 @@ by - Ben Alpert + Sophie Alpert @@ -723,85 +804,6 @@ Minified build for production: - - -

    - - React v0.14.3 - -

    - -

    - November 18, 2015 - by - - - Paul O’Shannessy - - - -

    - -
    - -
    -

    It's time for another installment of React patch releases! We didn't break anything in v0.14.2 but we do have a couple of other bugs we're fixing. The biggest change in this release is actually an addition of a new built file. We heard from a number of people that they still need the ability to use React to render to a string on the client. While the use cases are not common and there are other ways to achieve this, we decided that it's still valuable to support. So we're now building react-dom-server.js, which will be shipped to Bower and in the dist/ directory of the react-dom package on npm. This file works the same way as react-dom.js and therefore requires that the primary React build has already been included on the page.

    - -

    The release is now available for download:

    - - - -

    We've also published version 0.14.3 of the react, react-dom, and addons packages on npm and the react package on bower.

    - -
    - -

    Changelog

    - -

    React DOM

    - -
      -
    • Added support for nonce attribute for <script> and <style> elements
    • -
    • Added support for reversed attribute for <ol> elements
    • -
    - -

    React TestUtils Add-on

    - -
      -
    • Fixed bug with shallow rendering and function refs
    • -
    - -

    React CSSTransitionGroup Add-on

    - -
      -
    • Fixed bug resulting in timeouts firing incorrectly when mounting and unmounting rapidly
    • -
    - -

    React on Bower

    - -
      -
    • Added react-dom-server.js to expose renderToString and renderToStaticMarkup for usage in the browser
    • -
    - -
    - - -

    diff --git a/blog/page6/index.html b/blog/page6/index.html index 19e5f7638a..88eba4471b 100644 --- a/blog/page6/index.html +++ b/blog/page6/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,85 @@
    +

    + + React v0.14.3 + +

    + +

    + November 18, 2015 + by + + + Paul O’Shannessy + + + +

    + +
    + +
    +

    It's time for another installment of React patch releases! We didn't break anything in v0.14.2 but we do have a couple of other bugs we're fixing. The biggest change in this release is actually an addition of a new built file. We heard from a number of people that they still need the ability to use React to render to a string on the client. While the use cases are not common and there are other ways to achieve this, we decided that it's still valuable to support. So we're now building react-dom-server.js, which will be shipped to Bower and in the dist/ directory of the react-dom package on npm. This file works the same way as react-dom.js and therefore requires that the primary React build has already been included on the page.

    + +

    The release is now available for download:

    + + + +

    We've also published version 0.14.3 of the react, react-dom, and addons packages on npm and the react package on bower.

    + +
    + +

    Changelog

    + +

    React DOM

    + +
      +
    • Added support for nonce attribute for <script> and <style> elements
    • +
    • Added support for reversed attribute for <ol> elements
    • +
    + +

    React TestUtils Add-on

    + +
      +
    • Fixed bug with shallow rendering and function refs
    • +
    + +

    React CSSTransitionGroup Add-on

    + +
      +
    • Fixed bug resulting in timeouts firing incorrectly when mounting and unmounting rapidly
    • +
    + +

    React on Bower

    + +
      +
    • Added react-dom-server.js to expose renderToString and renderToStaticMarkup for usage in the browser
    • +
    + +
    + + + +
    + +
    + +

    React v0.14.2 @@ -368,7 +448,7 @@ Minified build for production: h by - Ben Alpert + Sophie Alpert @@ -586,152 +666,6 @@ Minified build for production: h -

    - -
    - - -

    - - ReactDOM.render and the Top Level React API - -

    - -

    - October 1, 2015 - by - - - Jim Sproch - - and - - - Sebastian Markbåge - - - -

    - -
    - -
    -

    When you're in React's world you are just building components that fit into other components. Everything is a component. Unfortunately not everything around you is built using React. At the root of your tree you still have to write some plumbing code to connect the outer world into React.

    - -

    The primary API for rendering into the DOM looks like this:

    -
    ReactDOM.render(reactElement, domContainerNode)
    -
    -

    To update the properties of an existing component, you call render again with a new element.

    - -

    If you are rendering React components within a single-page app, you may need to plug into the app's view lifecycle to ensure your app will invoke unmountComponentAtNode at the appropriate time. React will not automatically clean up a tree. You need to manually call:

    -
    ReactDOM.unmountComponentAtNode(domContainerNode)
    -
    -

    This is important and often forgotten. Forgetting to call unmountComponentAtNode will cause your app to leak memory. There is no way for us to automatically detect when it is appropriate to do this work. Every system is different.

    - -

    It is not unique to the DOM. If you want to insert a React Native view in the middle of an existing iOS app you will hit similar issues.

    - -

    Helpers

    - -

    If you have multiple React roots, or a single root that gets deleted over time, we recommend that you always create your own wrapper API. These will all look slightly different depending on what your outer system looks like. For example, at Facebook we have a system that automatically ties into our page transition router to automatically call unmountComponentAtNode.

    - -

    Rather than calling ReactDOM.render() directly everywhere, consider writing/using a library that will manage mounting and unmounting within your application.

    - -

    In your environment you may want to always configure internationalization, routers, user data etc. If you have many different React roots it can be a pain to set up configuration nodes all over the place. By creating your own wrapper you can unify that configuration into one place.

    - -

    Object Oriented Updates

    - -

    If you call ReactDOM.render a second time to update properties, all your props are completely replaced.

    -
    ReactDOM.render(<App locale="en-US" userID={1} />, container);
    -// props.userID == 1
    -// props.locale == "en-US"
    -ReactDOM.render(<App userID={2} />, container);
    -// props.userID == 2
    -// props.locale == undefined ??!?
    -
    -

    In object-oriented programming, all state lives on each object instance and you apply changes incrementally by mutating that state, one piece at a time. If you are using React within an app that expects an object oriented API (for instance, if you are building a custom web component using React), it might be surprising/confusing to a user that setting a single property would wipe out all the other properties on your component.

    - -

    We used to have a helper function called setProps which allowed you to update only a few properties at a time. Unfortunately this API lived on a component instance, required React to keep this state internally and wasn't very natural anyway. Therefore, we're deprecating it and suggest that you build it into your own wrapper instead.

    - -

    Here's some boilerplate to get you started. It is a 0.14 migration path for codebases using setProps and replaceProps.

    -
    class ReactComponentRenderer {
    -  constructor(klass, container) {
    -    this.klass = klass;
    -    this.container = container;
    -    this.props = {};
    -    this.component = null;
    -  }
    -
    -  replaceProps(props, callback) {
    -    this.props = {};
    -    this.setProps(props, callback);
    -  }
    -
    -  setProps(partialProps, callback) {
    -    if (this.klass == null) {
    -      console.warn(
    -        'setProps(...): Can only update a mounted or ' +
    -        'mounting component. This usually means you called setProps() on ' +
    -        'an unmounted component. This is a no-op.'
    -      );
    -      return;
    -    }
    -    Object.assign(this.props, partialProps);
    -    var element = React.createElement(this.klass, this.props);
    -    this.component = ReactDOM.render(element, this.container, callback);
    -  }
    -
    -  unmount() {
    -    ReactDOM.unmountComponentAtNode(this.container);
    -    this.klass = null;
    -  }
    -}
    -
    -

    Object-oriented APIs don't look like that though. They use setters and methods. I think we can do better. If you know more about the component API that you're rendering, you can create a more natural object-oriented API around your React component.

    -
    class ReactVideoPlayer {
    -  constructor(url, container) {
    -    this._container = container;
    -    this._url = url;
    -    this._isPlaying = false;
    -    this._render();
    -  }
    -
    -  _render() {
    -    ReactDOM.render(
    -      <VideoPlayer url={this._url} playing={this._isPlaying} />,
    -      this._container
    -    );
    -  }
    -
    -  get url() {
    -    return this._url;
    -  }
    -
    -  set url(value) {
    -    this._url = value;
    -    this._render();
    -  }
    -
    -  play() {
    -    this._isPlaying = true;
    -    this._render();
    -  }
    -
    -  pause() {
    -    this._isPlaying = false;
    -    this._render();
    -  }
    -
    -  destroy() {
    -    ReactDOM.unmountComponentAtNode(this._container);
    -  }
    -}
    -
    -

    This example shows how to provide an imperative API on top of a declarative one. Similarly, the reverse can be done, and a declarative wrapper can be used when exposing a Web Component as a React component.

    - -
    - - -
    diff --git a/blog/page7/index.html b/blog/page7/index.html index e6393c6f5f..5279e60d30 100644 --- a/blog/page7/index.html +++ b/blog/page7/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,152 @@
    +

    + + ReactDOM.render and the Top Level React API + +

    + +

    + October 1, 2015 + by + + + Jim Sproch + + and + + + Sebastian Markbåge + + + +

    + +
    + +
    +

    When you're in React's world you are just building components that fit into other components. Everything is a component. Unfortunately not everything around you is built using React. At the root of your tree you still have to write some plumbing code to connect the outer world into React.

    + +

    The primary API for rendering into the DOM looks like this:

    +
    ReactDOM.render(reactElement, domContainerNode)
    +
    +

    To update the properties of an existing component, you call render again with a new element.

    + +

    If you are rendering React components within a single-page app, you may need to plug into the app's view lifecycle to ensure your app will invoke unmountComponentAtNode at the appropriate time. React will not automatically clean up a tree. You need to manually call:

    +
    ReactDOM.unmountComponentAtNode(domContainerNode)
    +
    +

    This is important and often forgotten. Forgetting to call unmountComponentAtNode will cause your app to leak memory. There is no way for us to automatically detect when it is appropriate to do this work. Every system is different.

    + +

    It is not unique to the DOM. If you want to insert a React Native view in the middle of an existing iOS app you will hit similar issues.

    + +

    Helpers

    + +

    If you have multiple React roots, or a single root that gets deleted over time, we recommend that you always create your own wrapper API. These will all look slightly different depending on what your outer system looks like. For example, at Facebook we have a system that automatically ties into our page transition router to automatically call unmountComponentAtNode.

    + +

    Rather than calling ReactDOM.render() directly everywhere, consider writing/using a library that will manage mounting and unmounting within your application.

    + +

    In your environment you may want to always configure internationalization, routers, user data etc. If you have many different React roots it can be a pain to set up configuration nodes all over the place. By creating your own wrapper you can unify that configuration into one place.

    + +

    Object Oriented Updates

    + +

    If you call ReactDOM.render a second time to update properties, all your props are completely replaced.

    +
    ReactDOM.render(<App locale="en-US" userID={1} />, container);
    +// props.userID == 1
    +// props.locale == "en-US"
    +ReactDOM.render(<App userID={2} />, container);
    +// props.userID == 2
    +// props.locale == undefined ??!?
    +
    +

    In object-oriented programming, all state lives on each object instance and you apply changes incrementally by mutating that state, one piece at a time. If you are using React within an app that expects an object oriented API (for instance, if you are building a custom web component using React), it might be surprising/confusing to a user that setting a single property would wipe out all the other properties on your component.

    + +

    We used to have a helper function called setProps which allowed you to update only a few properties at a time. Unfortunately this API lived on a component instance, required React to keep this state internally and wasn't very natural anyway. Therefore, we're deprecating it and suggest that you build it into your own wrapper instead.

    + +

    Here's some boilerplate to get you started. It is a 0.14 migration path for codebases using setProps and replaceProps.

    +
    class ReactComponentRenderer {
    +  constructor(klass, container) {
    +    this.klass = klass;
    +    this.container = container;
    +    this.props = {};
    +    this.component = null;
    +  }
    +
    +  replaceProps(props, callback) {
    +    this.props = {};
    +    this.setProps(props, callback);
    +  }
    +
    +  setProps(partialProps, callback) {
    +    if (this.klass == null) {
    +      console.warn(
    +        'setProps(...): Can only update a mounted or ' +
    +        'mounting component. This usually means you called setProps() on ' +
    +        'an unmounted component. This is a no-op.'
    +      );
    +      return;
    +    }
    +    Object.assign(this.props, partialProps);
    +    var element = React.createElement(this.klass, this.props);
    +    this.component = ReactDOM.render(element, this.container, callback);
    +  }
    +
    +  unmount() {
    +    ReactDOM.unmountComponentAtNode(this.container);
    +    this.klass = null;
    +  }
    +}
    +
    +

    Object-oriented APIs don't look like that though. They use setters and methods. I think we can do better. If you know more about the component API that you're rendering, you can create a more natural object-oriented API around your React component.

    +
    class ReactVideoPlayer {
    +  constructor(url, container) {
    +    this._container = container;
    +    this._url = url;
    +    this._isPlaying = false;
    +    this._render();
    +  }
    +
    +  _render() {
    +    ReactDOM.render(
    +      <VideoPlayer url={this._url} playing={this._isPlaying} />,
    +      this._container
    +    );
    +  }
    +
    +  get url() {
    +    return this._url;
    +  }
    +
    +  set url(value) {
    +    this._url = value;
    +    this._render();
    +  }
    +
    +  play() {
    +    this._isPlaying = true;
    +    this._render();
    +  }
    +
    +  pause() {
    +    this._isPlaying = false;
    +    this._render();
    +  }
    +
    +  destroy() {
    +    ReactDOM.unmountComponentAtNode(this._container);
    +  }
    +}
    +
    +

    This example shows how to provide an imperative API on top of a declarative one. Similarly, the reverse can be done, and a declarative wrapper can be used when exposing a Web Component as a React component.

    + +
    + + + +
    + +
    + +

    Community Round-up #27 – Relay Edition @@ -225,7 +372,7 @@ by - Ben Alpert + Sophie Alpert @@ -432,7 +579,7 @@ Minified build for production: Ben Alpert + Sophie Alpert @@ -557,68 +704,6 @@ Minified build for production: - - -

    - - Relay Technical Preview - -

    - -

    - August 11, 2015 - by - - - Joseph Savona - - - -

    - -
    - -
    -

    Relay

    - -

    Today we're excited to share an update on Relay - the technical preview is now open-source and available on GitHub.

    - -

    Why Relay

    - -

    While React simplified the process of developing complex user-interfaces, it left open the question of how to interact with data on the server. It turns out that this was a significant source of friction for our developers; fragile coupling between client and server caused data-related bugs and made iteration harder. Furthermore, developers were forced to constantly re-implement complex async logic instead of focusing on their apps. Relay addresses these concerns by borrowing important lessons from React: it provides declarative, component-oriented data fetching for React applications.

    - -

    Declarative data-fetching means that Relay applications specify what data they need, not how to fetch that data. Just as React uses a description of the desired UI to manage view updates, Relay uses a data description in the form of GraphQL queries. Given these descriptions, Relay coalesces queries into batches for efficiency, manages error-prone asynchronous logic, caches data for performance, and automatically updates views as data changes.

    - -

    Relay is also component-oriented, extending the notion of a React component to include a description of what data is necessary to render it. This colocation allows developers to reason locally about their application and eliminates bugs such as under- or over-fetching data.

    - -

    Relay is in use at Facebook in production apps, and we're using it more and more because Relay lets developers focus on their products and move fast. It's working for us and we'd like to share it with the community.

    - -

    What's Included

    - -

    We're open-sourcing a technical preview of Relay - the core framework that we use internally, with some modifications for use outside Facebook. As this is the first release, it's good to keep in mind that there may be some incomplete or missing features. We'll continue to develop Relay and are working closely with the GraphQL community to ensure that Relay tracks updates during GraphQL's RFC period. But we couldn't wait any longer to get this in your hands, and we're looking forward to your feedback and contributions.

    - -

    Relay is available on GitHub and npm.

    - -

    What's Next

    - -

    The team is super excited to be releasing Relay - and just as excited about what's next. Here are some of the things we'll be focusing on:

    - -
      -
    • Offline support. This will allow applications to fulfill queries and enqueue updates without connectivity.
    • -
    • Real-time updates. In collaboration with the GraphQL community, we're working to define a specification for subscriptions and provide support for them in Relay.
    • -
    • A generic Relay. Just as the power of React was never about the virtual DOM, Relay is much more than a GraphQL client. We're working to extend Relay to provide a unified interface for interacting not only with server data, but also in-memory and native device data (and, even better, a mix of all three).
    • -
    • Finally, it's all too easy as developers to focus on those people with the newest devices and fastest internet connections. We're working to make it easier to build applications that are robust in the face of slow or intermittent connectivity.
    • -
    - -

    Thanks!

    - -
    - - -

    diff --git a/blog/page8/index.html b/blog/page8/index.html index d9542c58f0..d89ed0fd9c 100644 --- a/blog/page8/index.html +++ b/blog/page8/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,68 @@
    +

    + + Relay Technical Preview + +

    + +

    + August 11, 2015 + by + + + Joseph Savona + + + +

    + +
    + +
    +

    Relay

    + +

    Today we're excited to share an update on Relay - the technical preview is now open-source and available on GitHub.

    + +

    Why Relay

    + +

    While React simplified the process of developing complex user-interfaces, it left open the question of how to interact with data on the server. It turns out that this was a significant source of friction for our developers; fragile coupling between client and server caused data-related bugs and made iteration harder. Furthermore, developers were forced to constantly re-implement complex async logic instead of focusing on their apps. Relay addresses these concerns by borrowing important lessons from React: it provides declarative, component-oriented data fetching for React applications.

    + +

    Declarative data-fetching means that Relay applications specify what data they need, not how to fetch that data. Just as React uses a description of the desired UI to manage view updates, Relay uses a data description in the form of GraphQL queries. Given these descriptions, Relay coalesces queries into batches for efficiency, manages error-prone asynchronous logic, caches data for performance, and automatically updates views as data changes.

    + +

    Relay is also component-oriented, extending the notion of a React component to include a description of what data is necessary to render it. This colocation allows developers to reason locally about their application and eliminates bugs such as under- or over-fetching data.

    + +

    Relay is in use at Facebook in production apps, and we're using it more and more because Relay lets developers focus on their products and move fast. It's working for us and we'd like to share it with the community.

    + +

    What's Included

    + +

    We're open-sourcing a technical preview of Relay - the core framework that we use internally, with some modifications for use outside Facebook. As this is the first release, it's good to keep in mind that there may be some incomplete or missing features. We'll continue to develop Relay and are working closely with the GraphQL community to ensure that Relay tracks updates during GraphQL's RFC period. But we couldn't wait any longer to get this in your hands, and we're looking forward to your feedback and contributions.

    + +

    Relay is available on GitHub and npm.

    + +

    What's Next

    + +

    The team is super excited to be releasing Relay - and just as excited about what's next. Here are some of the things we'll be focusing on:

    + +
      +
    • Offline support. This will allow applications to fulfill queries and enqueue updates without connectivity.
    • +
    • Real-time updates. In collaboration with the GraphQL community, we're working to define a specification for subscriptions and provide support for them in Relay.
    • +
    • A generic Relay. Just as the power of React was never about the virtual DOM, Relay is much more than a GraphQL client. We're working to extend Relay to provide a unified interface for interacting not only with server data, but also in-memory and native device data (and, even better, a mix of all three).
    • +
    • Finally, it's all too easy as developers to focus on those people with the newest devices and fastest internet connections. We're working to make it easier to build applications that are robust in the face of slow or intermittent connectivity.
    • +
    + +

    Thanks!

    + +
    + + + +
    + +
    + +

    New React Devtools Beta @@ -242,7 +305,7 @@ for more info.

    by - Ben Alpert + Sophie Alpert @@ -424,81 +487,6 @@ for more info.

    -

    - -
    - - -

    - - React v0.13.3 - -

    - -

    - May 8, 2015 - by - - - Paul O’Shannessy - - - -

    - -
    - -
    -

    Today we're sharing another patch release in the v0.13 branch. There are only a few small changes, with a couple to address some issues that arose around that undocumented feature so many of you are already using: context. We also improved developer ergonomics just a little bit, making some warnings better.

    - -

    The release is now available for download:

    - - - -

    We've also published version 0.13.3 of the react and react-tools packages on npm and the react package on bower.

    - -
    - -

    Changelog

    - -

    React Core

    - -

    New Features

    - -
      -
    • Added clipPath element and attribute for SVG
    • -
    • Improved warnings for deprecated methods in plain JS classes
    • -
    - -

    Bug Fixes

    - -
      -
    • Loosened dangerouslySetInnerHTML restrictions so {__html: undefined} will no longer throw
    • -
    • Fixed extraneous context warning with non-pure getChildContext
    • -
    • Ensure replaceState(obj) retains prototype of obj
    • -
    - -

    React with Add-ons

    - -

    Bug Fixes

    - -
      -
    • Test Utils: Ensure that shallow rendering works when components define contextTypes
    • -
    - -
    - - -
    diff --git a/blog/page9/index.html b/blog/page9/index.html index d21fcbf3f9..bfd2d15891 100644 --- a/blog/page9/index.html +++ b/blog/page9/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -76,6 +77,8 @@

    Recent posts

    @@ -106,6 +107,81 @@
    +

    + + React v0.13.3 + +

    + +

    + May 8, 2015 + by + + + Paul O’Shannessy + + + +

    + +
    + +
    +

    Today we're sharing another patch release in the v0.13 branch. There are only a few small changes, with a couple to address some issues that arose around that undocumented feature so many of you are already using: context. We also improved developer ergonomics just a little bit, making some warnings better.

    + +

    The release is now available for download:

    + + + +

    We've also published version 0.13.3 of the react and react-tools packages on npm and the react package on bower.

    + +
    + +

    Changelog

    + +

    React Core

    + +

    New Features

    + +
      +
    • Added clipPath element and attribute for SVG
    • +
    • Improved warnings for deprecated methods in plain JS classes
    • +
    + +

    Bug Fixes

    + +
      +
    • Loosened dangerouslySetInnerHTML restrictions so {__html: undefined} will no longer throw
    • +
    • Fixed extraneous context warning with non-pure getChildContext
    • +
    • Ensure replaceState(obj) retains prototype of obj
    • +
    + +

    React with Add-ons

    + +

    Bug Fixes

    + +
      +
    • Test Utils: Ensure that shallow rendering works when components define contextTypes
    • +
    + +
    + + + +
    + +
    + +

    GraphQL Introduction @@ -473,49 +549,6 @@ Minified build for production: - - -

    - - Introducing React Native - -

    - -

    - March 26, 2015 - by - - - Ben Alpert - - - -

    - -
    - -
    -

    In January at React.js Conf, we announced React Native, a new framework for building native apps using React. We're happy to announce that we're open-sourcing React Native and you can start building your apps with it today.

    - -

    For more details, see Tom Occhino's post on the Facebook Engineering blog:

    - -
    -

    What we really want is the user experience of the native mobile platforms, combined with the developer experience we have when building with React on the web.

    - -

    With a bit of work, we can make it so the exact same React that's on GitHub can power truly native mobile applications. The only difference in the mobile environment is that instead of running React in the browser and rendering to divs and spans, we run it an embedded instance of JavaScriptCore inside our apps and render to higher-level platform-specific components.

    - -

    It's worth noting that we're not chasing “write once, run anywhere.” Different platforms have different looks, feels, and capabilities, and as such, we should still be developing discrete apps for each platform, but the same set of engineers should be able to build applications for whatever platform they choose, without needing to learn a fundamentally different set of technologies for each. We call this approach “learn once, write anywhere.”

    -
    - -

    To learn more, visit the React Native website.

    - -
    - - -

    diff --git a/community/conferences.html b/community/conferences.html index bf647f9b19..0b72341cce 100644 --- a/community/conferences.html +++ b/community/conferences.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -160,6 +161,12 @@

    Website

    +

    React Amsterdam 2018

    + +

    April 13 in Amsterdam, The Netherlands

    + +

    Website - Twitter - Facebook

    +

    Past Conferences

    React.js Conf 2015

    diff --git a/community/support.html b/community/support.html index 5c802bceac..954867d2c5 100644 --- a/community/support.html +++ b/community/support.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/community/videos.html b/community/videos.html index 6ac6c7bd9b..3e594c3cc5 100644 --- a/community/videos.html +++ b/community/videos.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/contributing/codebase-overview.html b/contributing/codebase-overview.html index 93df926a04..715c4b281c 100644 --- a/contributing/codebase-overview.html +++ b/contributing/codebase-overview.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -580,6 +581,11 @@ You can run npm run flow locally to check your code with Flow.

  • +
  • + Portals + +
  • +
  • Web Components @@ -650,6 +656,16 @@ You can run npm run flow locally to check your code with Flow.

  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/contributing/design-principles.html b/contributing/design-principles.html index 98fabfb685..9abfc3bf77 100644 --- a/contributing/design-principles.html +++ b/contributing/design-principles.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -363,6 +364,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -433,6 +439,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/contributing/how-to-contribute.html b/contributing/how-to-contribute.html index 079088e150..12d88c976d 100644 --- a/contributing/how-to-contribute.html +++ b/contributing/how-to-contribute.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -153,7 +154,6 @@
  • Format your code with prettier (npm run prettier).
  • Make sure your code lints (npm run lint).
  • Run the Flow typechecks (npm run flow).
  • -
  • If you added or removed any tests, run ./scripts/fiber/record-tests before submitting the pull request, and commit the resulting changes.
  • If you haven't already, complete the CLA.
  • @@ -370,6 +370,11 @@ You can check the status of your code styling by simply running npm run li +
  • + Portals + +
  • +
  • Web Components @@ -440,6 +445,16 @@ You can check the status of your code styling by simply running npm run li
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/contributing/implementation-notes.html b/contributing/implementation-notes.html index 9582e4cebe..354b1095a5 100644 --- a/contributing/implementation-notes.html +++ b/contributing/implementation-notes.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -1020,6 +1021,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -1090,6 +1096,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/crowdin.yaml b/crowdin.yaml new file mode 100644 index 0000000000..72f656d6fb --- /dev/null +++ b/crowdin.yaml @@ -0,0 +1,101 @@ +project_identifier_env: CROWDIN_REACT_PROJECT_ID +api_key_env: CROWDIN_REACT_API_KEY +base_path: "./" +preserve_hierarchy: true + +files: + - + source: '/docs/*.md' + translation: '/docs/i18n/%locale%/%original_file_name%' + languages_mapping: &anchor + locale: + 'af': 'af' + 'ar': 'ar' + 'bs-BA': 'bs-BA' + 'ca': 'ca' + 'cs': 'cs' + 'da': 'da' + 'de': 'de' + 'el': 'el' + 'es-ES': 'es-ES' + 'fa': 'fa-IR' + 'fi': 'fi' + 'fr': 'fr' + 'he': 'he' + 'hu': 'hu' + 'id': 'id-ID' + 'it': 'it' + 'ja': 'ja' + 'ko': 'ko' + 'mr': 'mr-IN' + 'nl': 'nl' + 'no': 'no-NO' + 'pl': 'pl' + 'pt-BR': 'pt-BR' + 'pt-PT': 'pt-PT' + 'ro': 'ro' + 'ru': 'ru' + 'sk': 'sk-SK' + 'sr': 'sr' + 'sv-SE': 'sv-SE' + 'tr': 'tr' + 'uk': 'uk' + 'vi': 'vi' + 'zh-CN': 'zh-Hans' + 'zh-TW': 'zh-Hant' + - + source: '/tutorial/*.md' + translation: '/tutorial/%locale%/%original_file_name%' + languages_mapping: *anchor + - + source: '/community/*.md' + translation: '/community/%locale%/%original_file_name%' + ignore: + - '/community/complementary-tools.it-IT.md' + - '/community/complementary-tools.ko-KR.md' + - '/community/complementary-tools.zh-CN.md' + - '/community/conferences.it-IT.md' + - '/community/conferences.ko-KR.md' + - '/community/conferences.zh-CN.md' + - '/community/examples.it-IT.md' + - '/community/examples.ko-KR.md' + - '/community/examples.zh-CN.md' + - '/community/videos.it-IT.md' + - '/community/videos.ko-KR.md' + - '/community/videos.zh-CN.md' + languages_mapping: *anchor + - + source: '/contributing/*.md' + translation: '/contributing/%locale%/%original_file_name%' + languages_mapping: *anchor + - + source: '/_data/*.yml' + translation: '/_data/%locale%/%original_file_name%' + languages_mapping: *anchor + ignore: + - '/_data/acknowledgements.yml' + - '/_data/authors.md' + - + source: '/warnings/*.md' + translation: '/warnings/%locale%/%original_file_name%' + languages_mapping: *anchor + - + source: '/index.md' + translation: '/%locale%/index.md' + languages_mapping: *anchor + - + source: '/README.md' + translation: '/%locale%/README.md' + languages_mapping: *anchor + - + source: '/acknowledgements.md' + translation: '/%locale%/acknowledgements.md' + languages_mapping: *anchor + - + source: '/404.md' + translation: '/%locale%/404.md' + languages_mapping: *anchor + - + source: '/jsx-compiler.md' + translation: '/%locale%/jsx-compiler.md' + languages_mapping: *anchor \ No newline at end of file diff --git a/docs/accessibility.html b/docs/accessibility.html index 4efc059b39..f160e34612 100644 --- a/docs/accessibility.html +++ b/docs/accessibility.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -335,7 +336,7 @@ to assistive technology, such as screen readers.

    Please note that browser / screen reader combinations matter. It is recommended that you test your application in the browser best suited to your screen reader of choice.

    -

    NVDA in FireFox

    +

    NVDA in Firefox

    NonVisual Desktop Access or NVDA is an open source Windows screen reader that is widely used.

    @@ -500,6 +501,11 @@ to assistive technology, such as screen readers.

    +
  • + Portals + +
  • +
  • Web Components @@ -570,6 +576,16 @@ to assistive technology, such as screen readers.

  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/addons.html b/docs/addons.html index cbed88dc04..5c5af09e62 100644 --- a/docs/addons.html +++ b/docs/addons.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -257,6 +258,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -327,6 +333,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/animation.html b/docs/animation.html index f8843f48f2..2833c62eda 100644 --- a/docs/animation.html +++ b/docs/animation.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -500,6 +501,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -570,6 +576,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/components-and-props.html b/docs/components-and-props.html index bbf7f925e8..319e2de2fd 100644 --- a/docs/components-and-props.html +++ b/docs/components-and-props.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -429,6 +430,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -499,6 +505,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/composition-vs-inheritance.html b/docs/composition-vs-inheritance.html index d9764670d9..d2fde2bb86 100644 --- a/docs/composition-vs-inheritance.html +++ b/docs/composition-vs-inheritance.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -361,6 +362,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -431,6 +437,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/conditional-rendering.html b/docs/conditional-rendering.html index 6c3e7c06fe..797801548b 100644 --- a/docs/conditional-rendering.html +++ b/docs/conditional-rendering.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -423,6 +424,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -493,6 +499,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/conferences-it-IT.html b/docs/conferences-it-IT.html index 7b2efc09fa..b7b42b0c0f 100644 --- a/docs/conferences-it-IT.html +++ b/docs/conferences-it-IT.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/docs/conferences-ko-KR.html b/docs/conferences-ko-KR.html index 2dfcbed29f..0fb1605ac3 100644 --- a/docs/conferences-ko-KR.html +++ b/docs/conferences-ko-KR.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/docs/conferences-zh-CN.html b/docs/conferences-zh-CN.html index 21e133e17b..f560ae51bd 100644 --- a/docs/conferences-zh-CN.html +++ b/docs/conferences-zh-CN.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/docs/context.html b/docs/context.html index 8bbf8c6bb4..66ff0416ca 100644 --- a/docs/context.html +++ b/docs/context.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -408,6 +409,11 @@ You can do this directly in React with the powerful "context" API.

    +
  • + Portals + +
  • +
  • Web Components @@ -478,6 +484,16 @@ You can do this directly in React with the powerful "context" API.

  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/create-fragment.html b/docs/create-fragment.html index a2644572f8..1eef666ac4 100644 --- a/docs/create-fragment.html +++ b/docs/create-fragment.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -124,7 +125,7 @@

    The keys of the passed object (that is, left and right) are used as keys for the entire set of children, and the order of the object's keys is used to determine the order of the rendered children. With this change, the two sets of children will be properly reordered in the DOM without unmounting.

    -

    The return value of createFragment should be treated as an opaque object; you can use the React.Children helpers to loop through a fragment but should not access it directly. Note also that we're relying on the JavaScript engine preserving object enumeration order here, which is not guaranteed by the spec but is implemented by all major browsers and VMs for objects with non-numeric keys.

    +

    The return value of createFragment should be treated as an opaque object; you can use the React.Children helpers to loop through a fragment but should not access it directly. Note also that we're relying on the JavaScript engine preserving object enumeration order here, which is not guaranteed by the spec but is implemented by all major browsers and VMs for objects with non-numeric keys.

    @@ -257,6 +258,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -327,6 +333,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • +
    diff --git a/docs/cross-origin-errors.html b/docs/cross-origin-errors.html index 66725efd19..f34f00e579 100644 --- a/docs/cross-origin-errors.html +++ b/docs/cross-origin-errors.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -236,6 +237,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -306,6 +312,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/dom-elements.html b/docs/dom-elements.html index 7dc88c7917..de8140bd26 100644 --- a/docs/dom-elements.html +++ b/docs/dom-elements.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -351,6 +352,11 @@ xmlLang xmlSpace y y1 y2 yChannelSelector z zoomAndPan +
  • + Portals + +
  • +
  • Web Components @@ -421,6 +427,16 @@ xmlLang xmlSpace y y1 y2 yChannelSelector z zoomAndPan
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/error-decoder.html b/docs/error-decoder.html index c3269d22f4..1f2472314e 100644 --- a/docs/error-decoder.html +++ b/docs/error-decoder.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -219,6 +220,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -289,6 +295,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/events.html b/docs/events.html index f08e7fdce3..3a88c89aef 100644 --- a/docs/events.html +++ b/docs/events.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -155,6 +156,7 @@ As such, you cannot access the event in an asynchronous way.

  • Image Events
  • Animation Events
  • Transition Events
  • +
  • Other Events

  • @@ -301,9 +303,9 @@ onMouseMove onMouseOut onMouseOver onMouseUp

    Media Events

    Event names:

    -
    onAbort onCanPlay onCanPlayThrough onDurationChange onEmptied onEncrypted 
    -onEnded onError onLoadedData onLoadedMetadata onLoadStart onPause onPlay 
    -onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend 
    +
    onAbort onCanPlay onCanPlayThrough onDurationChange onEmptied onEncrypted
    +onEnded onError onLoadedData onLoadedMetadata onLoadStart onPause onPlay
    +onPlaying onProgress onRateChange onSeeked onSeeking onStalled onSuspend
     onTimeUpdate onVolumeChange onWaiting
     

    @@ -336,6 +338,13 @@ onTimeUpdate onVolumeChange onWaiting
    string propertyName
     string pseudoElement
     float elapsedTime
    +
    +
    + +

    Other Events

    + +

    Event names:

    +
    onToggle
     
    @@ -468,6 +477,11 @@ onTimeUpdate onVolumeChange onWaiting +
  • + Portals + +
  • +
  • Web Components @@ -538,6 +552,16 @@ onTimeUpdate onVolumeChange onWaiting
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • +
    diff --git a/docs/forms.html b/docs/forms.html index f157289d59..b9be9ed903 100644 --- a/docs/forms.html +++ b/docs/forms.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@
    @@ -434,6 +435,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -504,6 +510,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/handling-events.html b/docs/handling-events.html index 1f63578f0d..13e9df26d7 100644 --- a/docs/handling-events.html +++ b/docs/handling-events.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -326,6 +327,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -396,6 +402,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/hello-world.html b/docs/hello-world.html index bbe4f2108f..10efabff74 100644 --- a/docs/hello-world.html +++ b/docs/hello-world.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -86,7 +87,7 @@ document.getElementById('root') );
    -

    It renders a header saying "Hello World" on the page.

    +

    It renders a header saying "Hello, world!" on the page.

    The next few sections will gradually introduce you to using React. We will examine the building blocks of React apps: elements and components. Once you master them, you can create complex apps from small reusable pieces.

    @@ -231,6 +232,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -301,6 +307,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/higher-order-components.html b/docs/higher-order-components.html index d31412215d..03ae139873 100644 --- a/docs/higher-order-components.html +++ b/docs/higher-order-components.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -307,7 +308,7 @@

    The most common signature for HOCs looks like this:

    // React Redux's `connect`
    -const ConnectedComment = connect(commentSelector, commentActions)(Comment);
    +const ConnectedComment = connect(commentSelector, commentActions)(CommentList);
     

    What?! If you break it apart, it's easier to see what's going on.

    // connect is a function that returns another function
    @@ -320,14 +321,14 @@
     
     

    This form may seem confusing or unnecessary, but it has a useful property. Single-argument HOCs like the one returned by the connect function have the signature Component => Component. Functions whose output type is the same as its input type are really easy to compose together.

    // Instead of doing this...
    -const EnhancedComponent = connect(commentSelector)(withRouter(WrappedComponent))
    +const EnhancedComponent = withRouter(connect(commentSelector)(WrappedComponent))
     
     // ... you can use a function composition utility
     // compose(f, g, h) is the same as (...args) => f(g(h(...args)))
     const enhance = compose(
       // These are both single-argument HOCs
    -  connect(commentSelector),
    -  withRouter
    +  withRouter,
    +  connect(commentSelector)
     )
     const EnhancedComponent = enhance(WrappedComponent)
     
    @@ -571,6 +572,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -641,6 +647,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • +
    diff --git a/docs/installation.html b/docs/installation.html index dc1cd3a94e..f95fd71608 100644 --- a/docs/installation.html +++ b/docs/installation.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -276,15 +277,15 @@ npm install --save react react-dom

    Using a CDN

    -

    If you don't want to use npm to manage client packages, the react and react-dom npm packages also provide single-file distributions in dist folders, which are hosted on a CDN:

    -
    <script crossorigin src="https://unpkg.com/react@15/dist/react.js"></script>
    -<script crossorigin src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script>
    +

    If you don't want to use npm to manage client packages, the react and react-dom npm packages also provide single-file distributions in umd folders, which are hosted on a CDN:

    +
    <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
    +<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
     

    The versions above are only meant for development, and are not suitable for production. Minified and optimized production versions of React are available at:

    -
    <script crossorigin src="https://unpkg.com/react@15/dist/react.min.js"></script>
    -<script crossorigin src="https://unpkg.com/react-dom@15/dist/react-dom.min.js"></script>
    +
    <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
    +<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
     
    -

    To load a specific version of react and react-dom, replace 15 with the version number.

    +

    To load a specific version of react and react-dom, replace 16 with the version number.

    If you use Bower, React is available via the react package.

    @@ -525,6 +526,11 @@ function selectTabForHashLink() { +
  • + Portals + +
  • +
  • Web Components @@ -595,6 +601,16 @@ function selectTabForHashLink() {
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • +
    diff --git a/docs/integrating-with-other-libraries.html b/docs/integrating-with-other-libraries.html index 93aba486b2..051898ac6d 100644 --- a/docs/integrating-with-other-libraries.html +++ b/docs/integrating-with-other-libraries.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@
    @@ -600,6 +601,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -670,6 +676,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/introducing-jsx.html b/docs/introducing-jsx.html index 816ed26f08..337aa38c47 100644 --- a/docs/introducing-jsx.html +++ b/docs/introducing-jsx.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -339,6 +340,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -409,6 +415,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/javascript-environment-requirements.html b/docs/javascript-environment-requirements.html new file mode 100644 index 0000000000..46f047e1b7 --- /dev/null +++ b/docs/javascript-environment-requirements.html @@ -0,0 +1,423 @@ + + + + + + + + + JavaScript Environment Requirements - React + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    +
    + Edit on GitHub +

    + JavaScript Environment Requirements +

    +
    + +

    React 16 depends on the collection types Map and Set. If you support older browsers and devices which may not yet provide these natively (e.g. IE < 11), consider including a global polyfill in your bundled application, such as core-js or babel-polyfill.

    + +

    A polyfilled environment for React 16 using core-js to support older browsers might look like:

    +
    import 'core-js/es6/map';
    +import 'core-js/es6/set';
    +
    +import React from 'react';
    +import ReactDOM from 'react-dom';
    +
    +ReactDOM.render(
    +  <h1>Hello, world!</h1>,
    +  document.getElementById('root')
    +);
    +
    +

    React also depends on requestAnimationFrame (even in test environments). A simple shim for testing environments would be:

    +
    global.requestAnimationFrame = function(callback) {
    +  setTimeout(callback, 0);
    +};
    +
    + +
    + + +
    +
    + + + +
    + + + + +
    + +
    + + + + diff --git a/docs/jsx-in-depth.html b/docs/jsx-in-depth.html index be59d17366..80a9c26d79 100644 --- a/docs/jsx-in-depth.html +++ b/docs/jsx-in-depth.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -531,6 +532,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -601,6 +607,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/lifting-state-up.html b/docs/lifting-state-up.html index 116bcd9223..f137842fd4 100644 --- a/docs/lifting-state-up.html +++ b/docs/lifting-state-up.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -493,6 +494,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -563,6 +569,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/lists-and-keys.html b/docs/lists-and-keys.html index 51c574920d..10e1fffc12 100644 --- a/docs/lists-and-keys.html +++ b/docs/lists-and-keys.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -463,6 +464,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -533,6 +539,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/optimizing-performance.html b/docs/optimizing-performance.html index 569e8950ff..67f790df27 100644 --- a/docs/optimizing-performance.html +++ b/docs/optimizing-performance.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -542,6 +543,11 @@ This section is only relevant if you configure webpack directly.

    +
  • + Portals + +
  • +
  • Web Components @@ -612,6 +618,16 @@ This section is only relevant if you configure webpack directly.

  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/perf.html b/docs/perf.html index 0ac58b1bb9..105ebd2047 100644 --- a/docs/perf.html +++ b/docs/perf.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -330,6 +331,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -400,6 +406,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/portals.html b/docs/portals.html new file mode 100644 index 0000000000..73de04aa08 --- /dev/null +++ b/docs/portals.html @@ -0,0 +1,479 @@ + + + + + + + + + Portals - React + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    +
    + Edit on GitHub +

    + Portals +

    +
    + +

    Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.

    +
    ReactDOM.createPortal(child, container)
    +
    +

    The first argument (child) is any renderable React child, such as an element, string, or fragment. The second argument (container) is a DOM element.

    + +

    Usage

    + +

    Normally, when you return an element from a component's render method, it's mounted into the DOM as a child of the nearest parent node:

    +
    render() {
    +  // React mounts a new div and renders the children into it
    +  return (
    +    <div>
    +      {this.props.children}
    +    </div>
    +  );
    +}
    +
    +

    However, sometimes it's useful to insert a child into a different location in the DOM:

    +
    render() {
    +  // React does *not* create a new div. It renders the children into `domNode`.
    +  // `domNode` is any valid DOM node, regardless of its location in the DOM.
    +  return React.createPortal(
    +    this.props.children,
    +    domNode,
    +  );
    +}
    +
    +

    A typical use case for portals is when a parent component has an overflow: hidden or z-index style, but you need the child to visually "break out" of its container. For example, dialogs, hovercards, and tooltips.

    + +
    +

    Note:

    + +

    For most uses portals, you'll need to make sure to follow the proper accessibility guidelines.

    +
    + +

    Try out an example on CodePen.

    + +

    Portals and event bubbling

    + +

    A nice feature of portals is that, even though the DOM node can be anywhere in the DOM tree, it behaves like a normal React child in every other way. Features like context work exactly the same regardless of whether the child is a portal.

    + +

    This includes event bubbling: an event fired from inside a portal will propagate to ancestors in the containing React tree, even if those elements are not ancestors in the DOM tree:

    +
    // These two containers are siblings in the DOM
    +const appContainer = document.getElementById('app-container');
    +const modalContainer = document.getElementById('modal-container');
    +
    +class Parent extends React.Component {
    +  state = {clicks: 0};
    +  onClick = () => {
    +    // This will fire when the button in Child is clicked, even though
    +    // button is not direct descendant in the DOM.
    +    this.setState(state => ({clicks: state.clicks + 1}));
    +  };
    +  render() {
    +    return (
    +      <div onClick={this.onClick}>
    +        <p>Number of clicks: {this.state.clicks}</p>
    +        <p>Open up the browser DevTools to observe that the button is not a child the div with onClick handler.</p>
    +        {ReactDOM.createPortal(<Child />, modalContainer)}
    +      </div>
    +    );
    +  }
    +}
    +
    +function Child() {
    +  return <button>Click</button>;
    +}
    +
    +
    +ReactDOM.render(<Parent />, appContainer);
    +
    +

    Try this example on CodePen.

    + +

    The advantage of treating portal event bubbling this way is that it makes it easier to build abstractions. For example, if you render a <Modal /> component, the parent can capture its events regardless of whether it's implemented using portals.

    + + +
    + + +
    +
    + + + +
    + + + + +
    + +
    + + + + diff --git a/docs/pure-render-mixin.html b/docs/pure-render-mixin.html index 04700ddfe5..c3a07af3b2 100644 --- a/docs/pure-render-mixin.html +++ b/docs/pure-render-mixin.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -251,6 +252,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -321,6 +327,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/react-api.html b/docs/react-api.html index d6a58c5f1f..14ece6c554 100644 --- a/docs/react-api.html +++ b/docs/react-api.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -364,6 +365,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -434,6 +440,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/react-component.html b/docs/react-component.html index c53c9cebc0..406d3fe78e 100644 --- a/docs/react-component.html +++ b/docs/react-component.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -160,9 +161,17 @@

    The render() method is required.

    -

    When called, it should examine this.props and this.state and return a single React element. This element can be either a representation of 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 one of the following types:

    -

    You can also return null or false to indicate that you don't want anything rendered. When returning null or false, ReactDOM.findDOMNode(this) will return null.

    + + +

    When returning null or false, ReactDOM.findDOMNode(this) will return null.

    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 directly interact with the browser. If you need to interact with the browser, perform your work in componentDidMount() or the other lifecycle methods instead. Keeping render() pure makes components easier to think about.

    @@ -172,6 +181,23 @@

    render() will not be invoked if shouldComponentUpdate() returns false.

    +

    Fragments

    + +

    You can also return multiple items from render() using an array:

    +
    render() {
    +  return [
    +    <li key="A"/>First item</li>,
    +    <li key="B"/>Second item</li>,
    +    <li key="C"/>Third item</li>,
    +  ];
    +}
    +
    +
    +

    Note:

    + +

    Don't forget to add keys to elements in a fragment to avoid the key warning.

    +
    +

    constructor()

    @@ -358,7 +384,7 @@

    displayName

    -

    The displayName string is used in debugging messages. JSX sets this value automatically; see JSX in Depth.

    +

    The displayName string is used in debugging messages. Usually, you don't need to set it explicitly because it's inferred from the name of the function or class that defines the component. You might want to set it explicitly if you want to display a different name for debugging purposes or when you create a higher-order component, see Wrap the Display Name for Easy Debugging for details.


    @@ -511,6 +537,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -581,6 +612,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/react-dom-server.html b/docs/react-dom-server.html index 9fc574c3b6..09b11557b8 100644 --- a/docs/react-dom-server.html +++ b/docs/react-dom-server.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -78,17 +79,38 @@
    -

    If you load React from a <script> tag, these top-level APIs are available on the ReactDOMServer global. If you use ES6 with npm, you can write import ReactDOMServer from 'react-dom/server'. If you use ES5 with npm, you can write var ReactDOMServer = require('react-dom/server').

    - +

    The ReactDOMServer object enables you to render components to static markup. Typically, it's used on a Node server:

    +
    // ES modules
    +import ReactDOMServer from 'react-dom/server';
    +// CommonJS
    +var ReactDOMServer = require('react-dom/server');
    +
    +

    We also provide a separate entry-point for use in the browser:

    +
    // ES modules
    +import ReactDOMServer from 'react-dom/server.browser';
    +// CommonJS
    +var ReactDOMServer = require('react-dom/server.browser');
    +
    +

    Or, using UMD:

    +
    <script crossorigin src="https://unpkg.com/react-dom/umd/react-dom-server.browser.production.min.js" />
    +<!-- Accessible as window.ReactDOMServer -->
    +

    Overview

    -

    The ReactDOMServer object allows you to render your components on the server.

    +

    The following methods can be used in both the server and browser environments:

    +

    These additional methods depend on a package (stream) that is only available on the server, and won't work in the browser.

    + + +

    Reference

    @@ -96,9 +118,9 @@

    renderToString()

    ReactDOMServer.renderToString(element)
     
    -

    Render a React element 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.

    +

    Render a React element to its initial HTML. 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 ReactDOM.render() 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.

    +

    If you call ReactDOM.hydrate() 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.


    @@ -107,6 +129,36 @@

    Similar to renderToString, except this doesn't create extra DOM attributes such as data-reactid, that React uses internally. This is useful if you want to use React as a simple static page generator, as stripping away the extra attributes can save lots of bytes.

    +
    + +

    renderToNodeStream()

    +
    ReactDOMNodeStream.renderToNodeStream(element)
    +
    +

    Render a React element to its initial HTML. Returns a Readable stream that outputs an HTML string. The HTML output by this stream is exactly equal to what ReactDOMServer.renderToString would return.

    + +
    +

    Note:

    + +

    Server-only. This API is not available in the browser.

    + +

    The stream returned from this method will return a byte stream encoded in utf-8. If you need a stream in another encoding, take a look a project like iconv-lite, which provides transform streams for transcoding text.

    +
    + +
    + +

    renderToStaticNodeStream()

    +
    ReactDOMNodeStream.renderToStaticNodeStream(element)
    +
    +

    Similar to renderToNodeStream, except this doesn't create extra DOM attributes such as data-reactid, that React uses internally. The HTML output by this stream is exactly equal to what ReactDOMServer.renderToStaticMarkup would return.

    + +
    +

    Note:

    + +

    Server-only. This API is not available in the browser.

    + +

    The stream returned from this method will return a byte stream encoded in utf-8. If you need a stream in another encoding, take a look a project like iconv-lite, which provides transform streams for transcoding text.

    +
    +
    @@ -238,6 +290,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -308,6 +365,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • +
    diff --git a/docs/react-dom.html b/docs/react-dom.html index 14b9f3d905..1d683f11e6 100644 --- a/docs/react-dom.html +++ b/docs/react-dom.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -86,8 +87,10 @@

    Browser Support

    @@ -127,10 +130,23 @@

    ReactDOM.render() currently returns a reference to the root ReactComponent instance. However, using this return value is legacy and should be avoided because future versions of React may render components asynchronously in some cases. If you need a reference to the root ReactComponent instance, the preferred solution is to attach a callback ref to the root element.

    + +

    Using ReactDOM.render() to hydrate a server-rendered container is deprecated and will be removed in React 17. Use hydrate() instead.


    +

    hydrate()

    +
    ReactDOM.hydrate(
    +  element,
    +  container,
    +  [callback]
    +)
    +
    +

    Same as render(), but is used to hydrate a container whose HTML contents were rendered by ReactDOMServer. React will attach event listeners while preserving as much of the existing DOM as possible. For best results, you should try to render the same content on the server as on the client, with as few differences as possible.

    + +
    +

    unmountComponentAtNode()

    ReactDOM.unmountComponentAtNode(container)
     
    @@ -153,6 +169,13 @@ and should be avoided because future versions of React may render components asy

    findDOMNode cannot be used on functional components.

    +
    + +

    createPortal()

    +
    ReactDOM.createPortal(child, container)
    +
    +

    Creates a portal. Portals provide a way to render children into a DOM node that exists outside the hierarchy of the DOM component.

    +
    @@ -284,6 +307,11 @@ and should be avoided because future versions of React may render components asy +
  • + Portals + +
  • +
  • Web Components @@ -354,6 +382,16 @@ and should be avoided because future versions of React may render components asy
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • +
    diff --git a/docs/react-without-es6.html b/docs/react-without-es6.html index bd7d0fdebd..c17920e4f8 100644 --- a/docs/react-without-es6.html +++ b/docs/react-without-es6.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -401,6 +402,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -471,6 +477,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/react-without-jsx.html b/docs/react-without-jsx.html index cfae5ca1ac..de6bfec56c 100644 --- a/docs/react-without-jsx.html +++ b/docs/react-without-jsx.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -253,6 +254,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -323,6 +329,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/reconciliation.html b/docs/reconciliation.html index 9291e5ec02..f9055f2d3c 100644 --- a/docs/reconciliation.html +++ b/docs/reconciliation.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -339,6 +340,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -409,6 +415,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/refs-and-the-dom.html b/docs/refs-and-the-dom.html index 6de728142c..979e80b1e0 100644 --- a/docs/refs-and-the-dom.html +++ b/docs/refs-and-the-dom.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -125,7 +126,7 @@ <input type="button" value="Focus the text input" - onClick={this.focus} + onClick={this.focusTextInput} /> </div> ); @@ -403,6 +404,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -473,6 +479,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/rendering-elements.html b/docs/rendering-elements.html index 58d8559bd5..ec6fff63f5 100644 --- a/docs/rendering-elements.html +++ b/docs/rendering-elements.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -109,7 +110,7 @@

    Try it on CodePen.

    -

    It displays "Hello World" on the page.

    +

    It displays "Hello, world" on the page.

    Updating the Rendered Element

    @@ -292,6 +293,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -362,6 +368,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/shallow-compare.html b/docs/shallow-compare.html index e86fdf9aec..2d5a259413 100644 --- a/docs/shallow-compare.html +++ b/docs/shallow-compare.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -242,6 +243,11 @@ It does this by iterating on the keys of the objects being compared and returnin +
  • + Portals + +
  • +
  • Web Components @@ -312,6 +318,16 @@ It does this by iterating on the keys of the objects being compared and returnin
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/shallow-renderer.html b/docs/shallow-renderer.html index 299a342c1c..8524fb0f49 100644 --- a/docs/shallow-renderer.html +++ b/docs/shallow-renderer.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -263,6 +264,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -333,6 +339,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/state-and-lifecycle.html b/docs/state-and-lifecycle.html index 4cfd237e57..1c2c1e5092 100644 --- a/docs/state-and-lifecycle.html +++ b/docs/state-and-lifecycle.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -603,6 +604,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -673,6 +679,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/test-renderer.html b/docs/test-renderer.html new file mode 100644 index 0000000000..911fa2855d --- /dev/null +++ b/docs/test-renderer.html @@ -0,0 +1,620 @@ + + + + + + + + + Test Renderer - React + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + +
    +
    + Edit on GitHub +

    + Test Renderer +

    +
    + +

    Importing

    +
    import TestRenderer from 'react-test-renderer'; // ES6
    +const TestRenderer = require('react-test-renderer'); // ES5 with npm
    +
    +

    Overview

    + +

    This package provides a React renderer that can be used to render React components to pure JavaScript objects, without depending on the DOM or a native mobile environment.

    + +

    Essentially, this package makes it easy to grab a snapshot of the platform view hierarchy (similar to a DOM tree) rendered by a React DOM or React Native component without using a browser or jsdom.

    + +

    Example:

    +
    import TestRenderer from 'react-test-renderer';
    +
    +function Link(props) {
    +  return <a href={props.page}>{props.children}</a>;
    +}
    +
    +const testRenderer = TestRenderer.create(
    +  <Link page="https://www.facebook.com/">Facebook</Link>
    +);
    +
    +console.log(testRenderer.toJSON());
    +// { type: 'a',
    +//   props: { href: 'https://www.facebook.com/' },
    +//   children: [ 'Facebook' ] }
    +
    +

    You can use Jest's snapshot testing feature to automatically save a copy of the JSON tree to a file and check in your tests that it hasn't changed: Learn more about it.

    + +

    You can also traverse the output to find specific nodes and make assertions about them.

    +
    import TestRenderer from 'react-test-renderer';
    +
    +function MyComponent() {
    +  return (
    +    <div>
    +      <SubComponent foo="bar" />
    +      <p className="my">Hello</p>
    +    </div>
    +  )
    +}
    +
    +function SubComponent() {
    +  return (
    +    <p className="sub">Sub</p>
    +  );
    +}
    +
    +const testRenderer = TestRenderer.create(<MyComponent />);
    +const testInstance = testRenderer.root;
    +
    +expect(testInstance.findByType(SubComponent).props.foo).toBe('bar');
    +expect(testInstance.findByProps({className: "sub"}).children).toEqual(['Sub']);
    +
    +

    TestRenderer

    + + + +

    TestRenderer instance

    + + + +

    TestInstance

    + + + +

    Reference

    + +

    TestRenderer.create()

    +
    TestRenderer.create(element, options);
    +
    +

    Create a TestRenderer instance with a passed element, which has the following methods and properties.

    + +

    testRenderer.toJSON()

    +
    testRenderer.toJSON()
    +
    +

    Return a JSON object representing the element.

    + +

    testRenderer.toTree()

    +
    testRenderer.toTree()
    +
    +

    Return a tree object representing the element.

    + +

    testRenderer.update()

    +
    testRenderer.update(element)
    +
    +

    Update the element with a passed element.

    + +

    testRenderer.unmount()

    +
    testRenderer.unmount()
    +
    +

    Unmount the element from testRenderer.

    + +

    testRenderer.getInstance()

    +
    testRenderer.getInstance()
    +
    +

    Return a root container instance.

    + +

    testRenderer.root

    +
    testRenderer.root
    +
    +

    root is a testInstance, which has the following methods and properties.

    + +

    testInstance.find()

    +
    testInstance.find(test)
    +
    +

    Find a descendant testInstance that test(testInstance) is true.

    + +

    testInstance.findByType()

    +
    testInstance.findByType(type)
    +
    +

    Find a descendant testInstance that matches the provided type.

    + +

    testInstance.findByProps()

    +
    testInstance.findByProps(props)
    +
    +

    Find a descendant testInstance that matches the provided props.

    + +

    testInstance.findAll()

    +
    testInstance.findAll(test)
    +
    +

    Find all descendant testInstances that test(testInstance) is true.

    + +

    testInstance.findAllByType()

    +
    testInstance.findAllByType(type)
    +
    +

    Find all descendant testInstances that matches the provided type.

    + +

    testInstance.findAllByProps()

    +
    testInstance.findAllByProps(props)
    +
    +

    Find all descendant testInstances that matches the provided props.

    + +

    testInstance.instance

    +
    testInstance.instance
    +
    +

    instance is a component instance of the testInstance.

    + +

    testInstance.type

    +
    testInstance.type
    +
    +

    type is a Component type of the testInstance.

    + +

    testInstance.props

    +
    testInstance.props
    +
    +

    props is a props object of the testInstance.

    + +

    testInstance.parent

    +
    testInstance.parent
    +
    +

    parent is a parent testInstance.

    + +

    testInstance.children

    +
    testInstance.children
    +
    +

    children is children of the testInstance.

    + +

    Ideas

    + +

    You can pass createNodeMock function to TestRenderer.create as the option, which allows for custom mock refs. +createNodeMock accepts the current element and should return a mock ref object. +This is useful when you test a component rely on refs.

    +
    import TestRenderer from 'react-test-renderer';
    +
    +class MyComponent extends React.Component {
    +  constructor(props) {
    +    super(props);
    +    this.input = null;
    +  }
    +  componentDidMount() {
    +    this.input.focus();
    +  }
    +  render() {
    +    return <input type="text" ref={el => this.input = el} />
    +  }
    +}
    +
    +let focused = false;
    +TestRenderer.create(
    +  <MyComponent />,
    +  {
    +    createNodeMock: (element) => {
    +      if (element.type === 'input') {
    +        // mock a focus function
    +        return {
    +          focus: () => {
    +            focused = true;
    +          }
    +        };
    +      }
    +      return null;
    +    }
    +  }
    +);
    +expect(focused).toBe(true);
    +
    + +
    + + +
    +
    + + + +
    + + + + +
    + +
    + + + + diff --git a/docs/test-utils.html b/docs/test-utils.html index 0b59f474f8..934a40618a 100644 --- a/docs/test-utils.html +++ b/docs/test-utils.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -420,6 +421,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -490,6 +496,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/thinking-in-react.html b/docs/thinking-in-react.html index 5831cc30ff..7a32e07c6f 100644 --- a/docs/thinking-in-react.html +++ b/docs/thinking-in-react.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -372,6 +373,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -442,6 +448,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/two-way-binding-helpers.html b/docs/two-way-binding-helpers.html index 55c2287df2..c722586ee1 100644 --- a/docs/two-way-binding-helpers.html +++ b/docs/two-way-binding-helpers.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -92,7 +93,7 @@

    LinkedStateMixin is an easy way to express two-way binding with React.

    -

    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. You can think of it as "one-way data binding."

    +

    In React, data flows one way: from owner to child. We think that this makes your app's code easier to understand. 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.

    @@ -322,6 +323,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -392,6 +398,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/typechecking-with-proptypes.html b/docs/typechecking-with-proptypes.html index 1a34146260..32e4930533 100644 --- a/docs/typechecking-with-proptypes.html +++ b/docs/typechecking-with-proptypes.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -363,6 +364,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -433,6 +439,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/uncontrolled-components.html b/docs/uncontrolled-components.html index db808a8b52..22cbeb3389 100644 --- a/docs/uncontrolled-components.html +++ b/docs/uncontrolled-components.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -264,6 +265,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -334,6 +340,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/update.html b/docs/update.html index 73509399a6..bafa4f10b6 100644 --- a/docs/update.html +++ b/docs/update.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -298,6 +299,11 @@ +
  • + Portals + +
  • +
  • Web Components @@ -368,6 +374,16 @@
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/docs/videos-it-IT.html b/docs/videos-it-IT.html index fb1a2b6053..7489202365 100644 --- a/docs/videos-it-IT.html +++ b/docs/videos-it-IT.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/docs/videos-ko-KR.html b/docs/videos-ko-KR.html index 8c7877eef4..c3e9ea8176 100644 --- a/docs/videos-ko-KR.html +++ b/docs/videos-ko-KR.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/docs/videos-zh-CN.html b/docs/videos-zh-CN.html index 012f04522a..fcff71df6f 100644 --- a/docs/videos-zh-CN.html +++ b/docs/videos-zh-CN.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/docs/web-components.html b/docs/web-components.html index fd3ebd62d3..a65e27b2a2 100644 --- a/docs/web-components.html +++ b/docs/web-components.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -254,6 +255,11 @@ You will need to manually attach event handlers to handle these events within yo +
  • + Portals + +
  • +
  • Web Components @@ -324,6 +330,16 @@ You will need to manually attach event handlers to handle these events within yo
  • +
  • + Test Renderer + +
  • + +
  • + JS Environment Requirements + +
  • + diff --git a/downloads/react-15.4.0-rc.3.zip b/downloads/react-15.4.0-rc.3.zip new file mode 100644 index 0000000000..d1a9786648 Binary files /dev/null and b/downloads/react-15.4.0-rc.3.zip differ diff --git a/downloads/react-15.4.1.zip b/downloads/react-15.4.1.zip deleted file mode 100644 index c29baf37e1..0000000000 Binary files a/downloads/react-15.4.1.zip and /dev/null differ diff --git a/feed.xml b/feed.xml index b65ce1a640..ea07047994 100644 --- a/feed.xml +++ b/feed.xml @@ -6,6 +6,206 @@ https://facebook.github.io/react + + React v16.0 + <p>We&#39;re excited to announce the release of React v16.0! Among the changes are some long-standing feature requests, including <a href="#new-render-return-types-fragments-and-strings"><strong>fragments</strong></a>, <a href="#better-error-handling"><strong>error boundaries</strong></a>, <a href="#portals"><strong>portals</strong></a>, support for <a href="#support-for-custom-dom-attributes"><strong>custom DOM attributes</strong></a>, improved <a href="#better-server-side-rendering"><strong>server-side rendering</strong></a>, and <a href="#reduced-file-size"><strong>reduced file size</strong></a>.</p> + +<h3>New render return types: fragments and strings</h3> + +<p>You can now return an array of elements from a component&#39;s <code>render</code> method. Like with other arrays, you&#39;ll need to add a key to each element to avoid the key warning:</p> +<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="nx">render</span><span class="p">()</span> <span class="p">{</span> + <span class="c1">// No need to wrap list items in an extra element!</span> + <span class="k">return</span> <span class="p">[</span> + <span class="c1">// Don&#39;t forget the keys :)</span> + <span class="o">&lt;</span><span class="nx">li</span> <span class="nx">key</span><span class="o">=</span><span class="s2">&quot;A&quot;</span><span class="o">&gt;</span><span class="nx">First</span> <span class="nx">item</span><span class="o">&lt;</span><span class="err">/li&gt;,</span> + <span class="o">&lt;</span><span class="nx">li</span> <span class="nx">key</span><span class="o">=</span><span class="s2">&quot;B&quot;</span><span class="o">&gt;</span><span class="nx">Second</span> <span class="nx">item</span><span class="o">&lt;</span><span class="err">/li&gt;,</span> + <span class="o">&lt;</span><span class="nx">li</span> <span class="nx">key</span><span class="o">=</span><span class="s2">&quot;C&quot;</span><span class="o">&gt;</span><span class="nx">Third</span> <span class="nx">item</span><span class="o">&lt;</span><span class="err">/li&gt;,</span> + <span class="p">];</span> +<span class="p">}</span> +</code></pre></div> +<p>In the future, we&#39;ll likely add a special fragment syntax to JSX that doesn&#39;t require keys.</p> + +<p>We&#39;ve added support for returning strings, too:</p> +<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="nx">render</span><span class="p">()</span> <span class="p">{</span> + <span class="k">return</span> <span class="s1">&#39;Look ma, no spans!&#39;</span><span class="p">;</span> +<span class="p">}</span> +</code></pre></div> +<p><a href="/react/docs/react-component.html#render">See the full list of supported return types</a>.</p> + +<h3>Better error handling</h3> + +<p>Previously, runtime errors during rendering could put React in a broken state, producing cryptic error messages and requiring a page refresh to recover. To address this problem, React 16 uses a more resilient error-handling strategy. By default, if an error is thrown inside a component&#39;s render or lifecycle methods, the whole component tree is unmounted from the root. This prevents the display of corrupted data. However, it&#39;s probably not the ideal user experience.</p> + +<p>Instead of unmounting the whole app every time there&#39;s an error, you can use error boundaries. Error boundaries are special components that capture errors inside their subtree and display a fallback UI in its place. Think of error boundaries like try-catch statements, but for React components.</p> + +<p>For more details, check out our <a href="/react/blog/2017/07/26/error-handling-in-react-16.html">previous post on error handling in React 16</a>.</p> + +<h3>Portals</h3> + +<p>Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.</p> +<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="nx">render</span><span class="p">()</span> <span class="p">{</span> + <span class="c1">// React does *not* create a new div. It renders the children into `domNode`.</span> + <span class="c1">// `domNode` is any valid DOM node, regardless of its location in the DOM.</span> + <span class="k">return</span> <span class="nx">ReactDOM</span><span class="p">.</span><span class="nx">createPortal</span><span class="p">(</span> + <span class="k">this</span><span class="p">.</span><span class="nx">props</span><span class="p">.</span><span class="nx">children</span><span class="p">,</span> + <span class="nx">domNode</span><span class="p">,</span> + <span class="p">);</span> +<span class="p">}</span> +</code></pre></div> +<p>See a full example in the <a href="/react/docs/portals.html">documentation for portals</a>.</p> + +<h3>Better server-side rendering</h3> + +<p>React 16 includes a completely rewritten server renderer. It&#39;s really fast. It supports <strong>streaming</strong>, so you can start sending bytes to the client faster. And thanks to a <a href="#reduced-file-size">new packaging strategy</a> that compiles away <code>process.env</code> checks (Believe it or not, reading <code>process.env</code> in Node is really slow!), you no longer need to bundle React to get good server-rendering performance.</p> + +<p>Core team member Sasha Aickin wrote a <a href="https://medium.com/@aickin/whats-new-with-server-side-rendering-in-react-16-9b0d78585d67">great article describing React 16&#39;s SSR improvements</a>. According to Sasha&#39;s synthetic benchmarks, server rendering in React 16 is roughly <strong>three times faster</strong> than React 15. &quot;When comparing against React 15 with <code>process.env</code> compiled out, there’s about a 2.4x improvement in Node 4, about a 3x performance improvement in Node 6, and a full 3.8x improvement in the new Node 8.4 release. And if you compare against React 15 without compilation, React 16 has a full order of magnitude gain in SSR in the latest version of Node!&quot; (As Sasha points out, please be aware that these numbers are based on synthetic benchmarks and may not reflect real-world performance.)</p> + +<p>In addition, React 16 is better at hydrating server-rendered HTML once it reaches the client. It no longer requires the initial render to exactly match the result from the server. Instead, it will attempt to reuse as much of the existing DOM as possible. No more checksums! In general, we don&#39;t recommend that you render different content on the client versus the server, but it can be useful in some cases (e.g. timestamps).</p> + +<p>See the <a href="/react/docs/react-dom-server.html">documentation for <code>ReactDOMServer</code></a> for more details.</p> + +<h3>Support for custom DOM attributes</h3> + +<p>Instead of ignoring unrecognized HTML and SVG attributes, React will now <a href="https://facebook.github.io/react/blog/2017/09/08/dom-attributes-in-react-16.html">pass them through to the DOM</a>. This has the added benefit of allowing us to get rid of most of React&#39;s attribute whitelist, resulting in reduced file sizes.</p> + +<h3>Reduced file size</h3> + +<p>Despite all these additions, React 16 is actually <strong>smaller</strong> compared to 15.6.1!</p> + +<ul> +<li><code>react</code> is 5.3 kb (2.2 kb gzipped), down from 20.7 kb (6.9 kb gzipped).</li> +<li><code>react-dom</code> is 103.7 kb (32.6 kb gzipped), down from 141 kb (42.9 kb gzipped).</li> +<li><code>react</code> + <code>react-dom</code> is 109 kb (34.8 kb gzipped), down from 161.7 kb (49.8 kb gzipped).</li> +</ul> + +<p>That amounts to a combined <strong>32% size decrease compared to the previous version (30% post-gzip)</strong>.</p> + +<p>The size difference is partly attributable to a change in packaging. React now uses <a href="https://rollupjs.org/">Rollup</a> to create flat bundles for each of its different target formats, resulting in both size and runtime performance wins. The flat bundle format also means that React&#39;s impact on bundle size is roughly consistent regardless of how your ship your app, whether it&#39;s with Webpack, Browserify, the pre-built UMD bundles, or any other system.</p> + +<h3>MIT licensed</h3> + +<p><a href="https://code.facebook.com/posts/300798627056246/relicensing-react-jest-flow-and-immutable-js/">In case you missed it</a>, React 16 is available under the MIT license. We&#39;ve also published React 15.6.2 under MIT, for those who are unable to upgrade immediately.</p> + +<h3>New core architecture</h3> + +<p>React 16 is the first version of React built on top of a new core architecture, codenamed &quot;Fiber.&quot; You can read all about this project over on <a href="https://code.facebook.com/posts/1716776591680069/react-16-a-look-inside-an-api-compatible-rewrite-of-our-frontend-ui-library/">Facebook&#39;s engineering blog</a>. (Spoiler: we rewrote React!)</p> + +<p>Fiber is responsible for most of the new features in React 16, like error boundaries and fragments. Over the next few releases, you can expect more new features as we begin to unlock the full potential of React.</p> + +<p>Perhaps the most exciting area we&#39;re working on is <strong>async rendering</strong>—a strategy for cooperatively scheduling rendering work by periodically yielding execution to the browser. The upshot is that, with async rendering, apps are more responsive because React avoids blocking the main thread.</p> + +<p>This demo provides an early peek at the types of problems async rendering can solve:</p> + +<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Ever wonder what &quot;async rendering&quot; means? Here&#39;s a demo of how to coordinate an async React tree with non-React work <a href="https://t.co/3snoahB3uV">https://t.co/3snoahB3uV</a> <a href="https://t.co/egQ988gBjR">pic.twitter.com/egQ988gBjR</a></p>&mdash; Andrew Clark (@acdlite) <a href="https://twitter.com/acdlite/status/909926793536094209">September 18, 2017</a></blockquote> + +<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> + +<p><em>Tip: Pay attention to the spinning black square.</em></p> + +<p>We think async rendering is a big deal, and represents the future of React. To make migration to v16.0 as smooth as possible, we&#39;re not enabling any async features yet, but we&#39;re excited to start rolling them out in the coming months. Stay tuned!</p> + +<h2>Installation</h2> + +<p>React v16.0.0 is available on the npm registry.</p> + +<p>To install React 16 with Yarn, run:</p> +<div class="highlight"><pre><code class="language-bash" data-lang="bash">yarn add react@^16.0.0 react-dom@^16.0.0 +</code></pre></div> +<p>To install React 16 with npm, run:</p> +<div class="highlight"><pre><code class="language-bash" data-lang="bash">npm install --save react@^16.0.0 react-dom@^16.0.0 +</code></pre></div> +<p>We also provide UMD builds of React via a CDN:</p> +<div class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt">&lt;script </span><span class="na">crossorigin</span> <span class="na">src=</span><span class="s">&quot;https://unpkg.com/react@16/umd/react.production.min.js&quot;</span><span class="nt">&gt;&lt;/script&gt;</span> +<span class="nt">&lt;script </span><span class="na">crossorigin</span> <span class="na">src=</span><span class="s">&quot;https://unpkg.com/react-dom@16/umd/react-dom.production.min.js&quot;</span><span class="nt">&gt;&lt;/script&gt;</span> +</code></pre></div> +<p>Refer to the documentation for <a href="/react/docs/installation.html">detailed installation instructions</a>.</p> + +<h2>Upgrading</h2> + +<p>Although React 16 includes significant internal changes, in terms of upgrading, you can think of this like any other major React release. We&#39;ve been serving React 16 to Facebook and Messenger.com users since earlier this year, and we released several beta and release candidate versions to flush out additional issues. With minor exceptions, <strong>if your app runs in 15.6 without any warnings, it should work in 16.</strong></p> + +<h3>New deprecations</h3> + +<p>Hydrating a server-rendered container now has an explicit API. If you&#39;re reviving server-rendered HTML, use <a href="/react/docs/react-dom.html#hydrate"><code>ReactDOM.hydrate</code></a> instead of <code>ReactDOM.render</code>. Keep using <code>ReactDOM.render</code> if you&#39;re just doing client-side rendering.</p> + +<h3>React Addons</h3> + +<p>As previously announced, we&#39;ve <a href="/react/blog/2017/04/07/react-v15.5.0.html#discontinuing-support-for-react-addons">discontinued support for React Addons</a>. We expect the latest version of each addon (except <code>react-addons-perf</code>; see below) to work for the foreseeable future, but we won&#39;t publish additional updates.</p> + +<p>Refer to the previous announcement for <a href="/react/blog/2017/04/07/react-v15.5.0.html#discontinuing-support-for-react-addons">suggestions on how to migrate</a>.</p> + +<p><code>react-addons-perf</code> no longer works at all in React 16. It&#39;s likely that we&#39;ll release a new version of this tool in the future. In the meantime, you can <a href="/react/docs/optimizing-performance.html#profiling-components-with-the-chrome-performance-tab">use your browser&#39;s performance tools to profile React components</a>.</p> + +<h3>Breaking changes</h3> + +<p>React 16 includes a number of small breaking changes. These only affect uncommon use cases and we don&#39;t expect them to break most apps.</p> + +<ul> +<li>React 15 had limited, undocumented support for error boundaries using <code>unstable_handleError</code>. This method has been renamed to <code>componentDidCatch</code>. You can use a codemod to <a href="https://github.com/reactjs/react-codemod#error-boundaries">automatically migrate to the new API</a>.</li> +<li><code>ReactDOM.render</code> and <code>ReactDOM.unstable_renderIntoContainer</code> now return null if called from inside a lifecycle method. To work around this, you can use <a href="https://github.com/facebook/react/issues/10309#issuecomment-318433235">portals</a> or <a href="https://github.com/facebook/react/issues/10309#issuecomment-318434635">refs</a>.</li> +<li><code>setState</code>: + +<ul> +<li>Calling <code>setState</code> with null no longer triggers an update. This allows you to decide in an updater function if you want to re-render.</li> +<li>Calling <code>setState</code> directly in render always causes an update. This was not previously the case. Regardless, you should not be calling setState from render.</li> +<li><code>setState</code> callbacks (second argument) now fire immediately after <code>componentDidMount</code> / <code>componentDidUpdate</code> instead of after all components have rendered.</li> +</ul></li> +<li>When replacing <code>&lt;A /&gt;</code> with <code>&lt;B /&gt;</code>, <code>B.componentWillMount</code> now always happens before <code>A.componentWillUnmount</code>. Previously, <code>A.componentWillUnmount</code> could fire first in some cases.</li> +<li>Previously, changing the ref to a component would always detach the ref before that component&#39;s render is called. Now, we change the ref later, when applying the changes to the DOM.</li> +<li>It is not safe to re-render into a container that was modified by something other than React. This worked previously in some cases but was never supported. We now emit a warning in this case. Instead you should clean up your component trees using <code>ReactDOM.unmountComponentAtNode</code>. <a href="https://github.com/facebook/react/issues/10294#issuecomment-318820987">See this example.</a></li> +<li><code>componentDidUpdate</code> lifecycle no longer receives <code>prevContext</code> param. (See <a href="https://github.com/facebook/react/issues/8631">#8631</a>)</li> +<li>Shallow renderer no longer calls <code>componentDidUpdate</code> because DOM refs are not available. This also makes it consistent with <code>componentDidMount</code> (which does not get called in previous versions either).</li> +<li>Shallow renderer does not implement <code>unstable_batchedUpdates</code> anymore.</li> +</ul> + +<h3>Packaging</h3> + +<ul> +<li>There is no <code>react/lib/*</code> and <code>react-dom/lib/*</code> anymore. Even in CommonJS environments, React and ReactDOM are precompiled to single files (“flat bundles”). If you previously relied on undocumented React internals, and they don’t work anymore, let us know about your specific case in a new issue, and we’ll try to figure out a migration strategy for you.</li> +<li>There is no <code>react-with-addons.js</code> build anymore. All compatible addons are published separately on npm, and have single-file browser versions if you need them.</li> +<li>The deprecations introduced in 15.x have been removed from the core package. <code>React.createClass</code> is now available as <code>create-react-class</code>, <code>React.PropTypes</code> as <code>prop-types</code>, <code>React.DOM</code> as <code>react-dom-factories</code>, <code>react-addons-test-utils</code> as <code>react-dom/test-utils</code>, and shallow renderer as <code>react-test-renderer/shallow</code>. See <a href="https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html">15.5.0</a> and <a href="https://facebook.github.io/react/blog/2017/06/13/react-v15.6.0.html">15.6.0</a> blog posts for instructions on migrating code and automated codemods.</li> +<li>The names and paths to the single-file browser builds have changed to emphasize the difference between development and production builds. For example: + +<ul> +<li><code>react/dist/react.js</code> → <code>react/umd/react.development.js</code></li> +<li><code>react/dist/react.min.js</code> → <code>react/umd/react.production.min.js</code></li> +<li><code>react-dom/dist/react-dom.js</code> → <code>react-dom/umd/react-dom.development.js</code></li> +<li><code>react-dom/dist/react-dom.min</code>.js → <code>react-dom/umd/react-dom.production.min.js</code></li> +</ul></li> +</ul> + +<h2>JavaScript Environment Requirements</h2> + +<p>React 16 depends on the collection types <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map">Map</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set">Set</a>. If you support older browsers and devices which may not yet provide these natively (e.g. IE &lt; 11), consider including a global polyfill in your bundled application, such as <a href="https://github.com/zloirock/core-js">core-js</a> or <a href="https://babeljs.io/docs/usage/polyfill/">babel-polyfill</a>.</p> + +<p>A polyfilled environment for React 16 using core-js to support older browsers might look like:</p> +<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="kr">import</span> <span class="s1">&#39;core-js/es6/map&#39;</span><span class="p">;</span> +<span class="kr">import</span> <span class="s1">&#39;core-js/es6/set&#39;</span><span class="p">;</span> + +<span class="kr">import</span> <span class="nx">React</span> <span class="nx">from</span> <span class="s1">&#39;react&#39;</span><span class="p">;</span> +<span class="kr">import</span> <span class="nx">ReactDOM</span> <span class="nx">from</span> <span class="s1">&#39;react-dom&#39;</span><span class="p">;</span> + +<span class="nx">ReactDOM</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span> + <span class="o">&lt;</span><span class="nx">h1</span><span class="o">&gt;</span><span class="nx">Hello</span><span class="p">,</span> <span class="nx">world</span><span class="o">!&lt;</span><span class="err">/h1&gt;,</span> + <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">&#39;root&#39;</span><span class="p">)</span> +<span class="p">);</span> +</code></pre></div> +<p>React also depends on <code>requestAnimationFrame</code> (even in test environments). A simple shim for test environments would be:</p> +<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="nx">global</span><span class="p">.</span><span class="nx">requestAnimationFrame</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">callback</span><span class="p">)</span> <span class="p">{</span> + <span class="nx">setTimeout</span><span class="p">(</span><span class="nx">callback</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> +<span class="p">};</span> +</code></pre></div> +<h2>Acknowledgments</h2> + +<p>As always, this release would not have been possible without our open source contributors. Thanks to everyone who filed bugs, opened PRs, responded to issues, wrote documentation, and more!</p> + +<p>Special thanks to our core contributors, especially for their heroic efforts over the past few weeks during the prerelease cycle: <a href="https://twitter.com/aweary">Brandon Dail</a>, <a href="https://twitter.com/monasticpanic">Jason Quense</a>, <a href="https://twitter.com/natehunzaker">Nathan Hunzaker</a>, and <a href="https://twitter.com/xander76">Sasha Aickin</a>.</p> + + 2017-09-26T00:00:00-07:00 + https://facebook.github.io/react/blog/2017/09/26/react-v16.0.html + https://facebook.github.io/react/blog/2017/09/26/react-v16.0.html + + React v15.6.2 <p>Today we&#39;re sending out React 15.6.2. In 15.6.1, we shipped a few fixes for change events and inputs that had some unintended consequences. Those regressions have been ironed out, and we&#39;ve also included a few more fixes to improve the stability of React across all browsers.</p> @@ -1199,7 +1399,7 @@ I think we should just treat arrays of elements as a frag. This is useful for co <ul> <li>In March we added support for server-side rendering and for creating multiple instances of Relay on a single page. This was a coordinated effort over the course of several months by community members <a href="https://github.com/denvned">Denis Nedelyaev</a> and <a href="https://github.com/devknoll">Gerald Monaco</a> (now at Facebook).</li> -<li>Also in March we added support for React Native. While we use Relay and React Native together internally, they didn&#39;t quite work together in open-source out of the box. We owe a big thanks to <a href="https://github.com/skevy">Adam Miskiewicz</a>, <a href="https://github.com/boourns">Tom Burns</a>, <a href="https://github.com/gre">Gaëtan Renaudeau</a>, <a href="https://github.com/davidaurelio">David Aurelio</a>, <a href="https://github.com/martinbigio">Martín Bigio</a>, <a href="https://github.com/zpao">Paul O’Shannessy</a>, <a href="https://github.com/spicyj">Ben Alpert</a>, and many others who helped track down and resolve issues. Finally, thanks to <a href="https://github.com/steveluscher">Steven Luscher</a> for coordinating this effort and building the first Relay/ReactNative example app.</li> +<li>Also in March we added support for React Native. While we use Relay and React Native together internally, they didn&#39;t quite work together in open-source out of the box. We owe a big thanks to <a href="https://github.com/skevy">Adam Miskiewicz</a>, <a href="https://github.com/boourns">Tom Burns</a>, <a href="https://github.com/gre">Gaëtan Renaudeau</a>, <a href="https://github.com/davidaurelio">David Aurelio</a>, <a href="https://github.com/martinbigio">Martín Bigio</a>, <a href="https://github.com/zpao">Paul O’Shannessy</a>, <a href="https://github.com/sophiebits">Sophie Alpert</a>, and many others who helped track down and resolve issues. Finally, thanks to <a href="https://github.com/steveluscher">Steven Luscher</a> for coordinating this effort and building the first Relay/ReactNative example app.</li> </ul> <p>We&#39;ve also seen some great open-source projects spring up around Relay:</p> @@ -1273,166 +1473,5 @@ I think we should just treat arrays of elements as a frag. This is useful for co https://facebook.github.io/react/blog/2016/08/05/relay-state-of-the-state.html - - Create Apps with No Configuration - <p><strong><a href="https://github.com/facebookincubator/create-react-app">Create React App</a></strong> is a new officially supported way to create single-page React applications. It offers a modern build setup with no configuration.</p> - -<h2>Getting Started</h2> - -<h3>Installation</h3> - -<p>First, install the global package:</p> -<div class="highlight"><pre><code class="language-sh" data-lang="sh">npm install -g create-react-app -</code></pre></div> -<p>Node.js 4.x or higher is required.</p> - -<h3>Creating an App</h3> - -<p>Now you can use it to create a new app:</p> -<div class="highlight"><pre><code class="language-sh" data-lang="sh">create-react-app hello-world -</code></pre></div> -<p>This will take a while as npm installs the transitive dependencies, but once it’s done, you will see a list of commands you can run in the created folder:</p> - -<p><img src="/react/img/blog/create-apps-with-no-configuration/created-folder.png" alt="created folder"></p> - -<h3>Starting the Server</h3> - -<p>Run <code>npm start</code> to launch the development server. The browser will open automatically with the created app’s URL.</p> - -<p><img src="/react/img/blog/create-apps-with-no-configuration/compiled-successfully.png" alt="compiled successfully"></p> - -<p>Create React App uses both webpack and Babel under the hood. -The console output is tuned to be minimal to help you focus on the problems:</p> - -<p><img src="/react/img/blog/create-apps-with-no-configuration/failed-to-compile.png" alt="failed to compile"></p> - -<p>ESLint is also integrated so lint warnings are displayed right in the console:</p> - -<p><img src="/react/img/blog/create-apps-with-no-configuration/compiled-with-warnings.png" alt="compiled with warnings"></p> - -<p>We only picked a small subset of lint rules that often lead to bugs.</p> - -<h3>Building for Production</h3> - -<p>To build an optimized bundle, run <code>npm run build</code>:</p> - -<p><img src="/react/img/blog/create-apps-with-no-configuration/npm-run-build.png" alt="npm run build"></p> - -<p>It is minified, correctly envified, and the assets include content hashes for caching.</p> - -<h3>One Dependency</h3> - -<p>Your <code>package.json</code> contains only a single build dependency and a few scripts:</p> -<div class="highlight"><pre><code class="language-js" data-lang="js"><span class="p">{</span> - <span class="s2">&quot;name&quot;</span><span class="o">:</span> <span class="s2">&quot;hello-world&quot;</span><span class="p">,</span> - <span class="s2">&quot;dependencies&quot;</span><span class="o">:</span> <span class="p">{</span> - <span class="s2">&quot;react&quot;</span><span class="o">:</span> <span class="s2">&quot;^15.2.1&quot;</span><span class="p">,</span> - <span class="s2">&quot;react-dom&quot;</span><span class="o">:</span> <span class="s2">&quot;^15.2.1&quot;</span> - <span class="p">},</span> - <span class="s2">&quot;devDependencies&quot;</span><span class="o">:</span> <span class="p">{</span> - <span class="s2">&quot;react-scripts&quot;</span><span class="o">:</span> <span class="s2">&quot;0.1.0&quot;</span> - <span class="p">},</span> - <span class="s2">&quot;scripts&quot;</span><span class="o">:</span> <span class="p">{</span> - <span class="s2">&quot;start&quot;</span><span class="o">:</span> <span class="s2">&quot;react-scripts start&quot;</span><span class="p">,</span> - <span class="s2">&quot;build&quot;</span><span class="o">:</span> <span class="s2">&quot;react-scripts build&quot;</span><span class="p">,</span> - <span class="s2">&quot;eject&quot;</span><span class="o">:</span> <span class="s2">&quot;react-scripts eject&quot;</span> - <span class="p">}</span> -<span class="p">}</span> -</code></pre></div> -<p>We take care of updating Babel, ESLint, and webpack to stable compatible versions so you can update a single dependency to get them all.</p> - -<h3>Zero Configuration</h3> - -<p>It is worth repeating: there are no configuration files or complicated folder structures. The tool only generates the files you need to build your app.</p> -<div class="highlight"><pre><code class="language-text" data-lang="text">hello-world/ - README.md - index.html - favicon.ico - node_modules/ - package.json - src/ - App.css - App.js - index.css - index.js - logo.svg -</code></pre></div> -<p>All the build settings are preconfigured and can’t be changed. Some features, such as testing, are currently missing. This is an intentional limitation, and we recognize it might not work for everybody. And this brings us to the last point.</p> - -<h3>No Lock-In</h3> - -<p>We first saw this feature in <a href="https://github.com/eanplatter/enclave">Enclave</a>, and we loved it. We talked to <a href="https://twitter.com/EanPlatter">Ean</a>, and he was excited to collaborate with us. He already sent a few pull requests!</p> - -<p>“Ejecting” lets you leave the comfort of Create React App setup at any time. You run a single command, and all the build dependencies, configs, and scripts are moved right into your project. At this point you can customize everything you want, but effectively you are forking our configuration and going your own way. If you’re experienced with build tooling and prefer to fine-tune everything to your taste, this lets you use Create React App as a boilerplate generator.</p> - -<p>We expect that at early stages, many people will “eject” for one reason or another, but as we learn from them, we will make the default setup more and more compelling while still providing no configuration.</p> - -<h2>Try It Out!</h2> - -<p>You can find <a href="https://github.com/facebookincubator/create-react-app"><strong>Create React App</strong></a> with additional instructions on GitHub.</p> - -<p>This is an experiment, and only time will tell if it becomes a popular way of creating and building React apps, or fades into obscurity.</p> - -<p>We welcome you to participate in this experiment. Help us build the React tooling that more people can use. We are always <a href="https://github.com/facebookincubator/create-react-app/issues/11">open to feedback</a>.</p> - -<h2>The Backstory</h2> - -<p>React was one of the first libraries to embrace transpiling JavaScript. As a result, even though you can <a href="https://github.com/facebook/react/blob/3fd582643ef3d222a00a0c756292c15b88f9f83c/examples/basic-jsx/index.html">learn React without any tooling</a>, the React ecosystem has commonly become associated with an overwhelming explosion of tools.</p> - -<p>Eric Clemmons called this phenomenon the “<a href="https://medium.com/@ericclemmons/javascript-fatigue-48d4011b6fc4">JavaScript Fatigue</a>”:</p> - -<blockquote> -<p>Ultimately, the problem is that by choosing React (and inherently JSX), you’ve unwittingly opted into a confusing nest of build tools, boilerplate, linters, &amp; time-sinks to deal with before you ever get to create anything.</p> -</blockquote> - -<p>It is tempting to write code in ES2015 and JSX. It is sensible to use a bundler to keep the codebase modular, and a linter to catch the common mistakes. It is nice to have a development server with fast rebuilds, and a command to produce optimized bundles for production.</p> - -<p>Combining these tools requires some experience with each of them. Even so, it is far too easy to get dragged into fighting small incompatibilities, unsatisfied peerDependencies, and illegible configuration files.</p> - -<p>Many of those tools are plugin platforms and don’t directly acknowledge each other’s existence. They leave it up to the users to wire them together. The tools mature and change independently, and tutorials quickly get out of date.</p> - -<blockquote class="twitter-tweet" data-lang="en"><p lang="en" dir="ltr">Marc was almost ready to implement his &quot;hello world&quot; React app <a href="https://t.co/ptdg4yteF1">pic.twitter.com/ptdg4yteF1</a></p>&mdash; Thomas Fuchs (@thomasfuchs) <a href="https://twitter.com/thomasfuchs/status/708675139253174273">March 12, 2016</a></blockquote> - -<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> - -<p>This doesn’t mean those tools aren’t great. To many of us, they have become indispensable, and we very much appreciate the effort of their maintainers. They already have too much on their plates to worry about the state of the React ecosystem.</p> - -<p>Still, we knew it was frustrating to spend days setting up a project when all you wanted was to learn React. We wanted to fix this.</p> - -<h2>Could We Fix This?</h2> - -<p>We found ourselves in an unusual dilemma.</p> - -<p>So far, <a href="/react/contributing/design-principles.html#dogfooding">our strategy</a> has been to only release the code that we are using at Facebook. This helped us ensure that every project is battle-tested and has clearly defined scope and priorities.</p> - -<p>However, tooling at Facebook is different than at many smaller companies. Linting, transpilation, and packaging are all handled by powerful remote development servers, and product engineers don’t need to configure them. While we wish we could give a dedicated server to every user of React, even Facebook cannot scale that well!</p> - -<p>The React community is very important to us. We knew that we couldn’t fix the problem within the limits of our open source philosophy. This is why we decided to make an exception, and to ship something that we didn’t use ourselves, but that we thought would be useful to the community.</p> - -<h2>The Quest for a React <abbr title="Command Line Interface">CLI</abbr></h2> - -<p>Having just attended <a href="http://embercamp.com/">EmberCamp</a> a week ago, I was excited about <a href="https://ember-cli.com/">Ember CLI</a>. Ember users have a great “getting started” experience thanks to a curated set of tools united under a single command-line interface. I have heard similar feedback about <a href="https://github.com/elm-lang/elm-reactor">Elm Reactor</a>.</p> - -<p>Providing a cohesive curated experience is valuable by itself, even if the user could in theory assemble those parts themselves. Kathy Sierra <a href="http://seriouspony.com/blog/2013/7/24/your-app-makes-me-fat">explains it best</a>:</p> - -<blockquote> -<p>If your UX asks the user to make <em>choices</em>, for example, even if those choices are both clear and useful, the act of <em>deciding</em> is a cognitive drain. And not just <em>while</em> they’re deciding... even <em>after</em> we choose, an unconscious cognitive background thread is slowly consuming/leaking resources, “Was <em>that</em> the right choice?”</p> -</blockquote> - -<p>I never tried to write a command-line tool for React apps, and neither has <a href="https://twitter.com/vjeux">Christopher</a>. We were chatting on Messenger about this idea, and we decided to work together on it for a week as a hackathon project.</p> - -<p>We knew that such projects traditionally haven’t been very successful in the React ecosystem. Christopher told me that multiple “React CLI” projects have started and failed at Facebook. The community tools with similar goals also exist, but so far they have not yet gained enough traction.</p> - -<p>Still, we decided it was worth another shot. Christopher and I created a very rough proof of concept on the weekend, and <a href="https://twitter.com/lacker">Kevin</a> soon joined us.</p> - -<p>We invited some of the community members to collaborate with us, and we have spent this week working on this tool. We hope that you’ll enjoy using it! <a href="https://github.com/facebookincubator/create-react-app/issues/11">Let us know what you think.</a></p> - -<p>We would like to express our gratitude to <a href="https://twitter.com/mxstbr">Max Stoiber</a>, <a href="https://twitter.com/jbscript">Jonny Buchanan</a>, <a href="https://twitter.com/eanplatter">Ean Platter</a>, <a href="https://github.com/tylermcginnis">Tyler McGinnis</a>, <a href="https://github.com/kentcdodds">Kent C. Dodds</a>, and <a href="https://twitter.com/ericclemmons">Eric Clemmons</a> for their early feedback, ideas, and contributions.</p> - - 2016-07-22T00:00:00-07:00 - https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html - https://facebook.github.io/react/blog/2016/07/22/create-apps-with-no-configuration.html - - diff --git a/index.html b/index.html index 88df801e90..dc3b32bc2c 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/js/ErrorDecoderComponent.js b/js/ErrorDecoderComponent.js index 090fb9d151..41d34eb78a 100644 --- a/js/ErrorDecoderComponent.js +++ b/js/ErrorDecoderComponent.js @@ -7,8 +7,6 @@ /* global React ReactDOM errorMap:true */ 'use strict'; -var _jsxFileName = '_js/ErrorDecoderComponent.js'; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } @@ -32,11 +30,7 @@ function urlify(str) { if (i % 2 === 1) { segments[i] = React.createElement( 'a', - { key: i, target: '_blank', href: segments[i], __source: { - fileName: _jsxFileName, - lineNumber: 25 - } - }, + { key: i, target: '_blank', href: segments[i] }, segments[i] ); } @@ -75,42 +69,22 @@ function ErrorResult(props) { if (!code) { return React.createElement( 'p', - { - __source: { - fileName: _jsxFileName, - lineNumber: 61 - } - }, + null, 'When you encounter an error, you\'ll receive a link to this page for that specific error and we\'ll show you the full error text.' ); } return React.createElement( 'div', - { - __source: { - fileName: _jsxFileName, - lineNumber: 66 - } - }, + null, React.createElement( 'p', - { - __source: { - fileName: _jsxFileName, - lineNumber: 67 - } - }, + null, 'The full text of the error you just encountered is:' ), React.createElement( 'code', - { - __source: { - fileName: _jsxFileName, - lineNumber: 68 - } - }, + null, urlify(errorMsg) ) ); @@ -153,20 +127,11 @@ var ErrorDecoder = function (_React$Component) { ErrorDecoder.prototype.render = function render() { return React.createElement(ErrorResult, { code: this.state.code, - msg: this.state.errorMsg, - __source: { - fileName: _jsxFileName, - lineNumber: 98 - } + msg: this.state.errorMsg }); }; return ErrorDecoder; }(React.Component); -ReactDOM.render(React.createElement(ErrorDecoder, { - __source: { - fileName: _jsxFileName, - lineNumber: 107 - } -}), document.querySelector('.error-decoder-container')); \ No newline at end of file +ReactDOM.render(React.createElement(ErrorDecoder, null), document.querySelector('.error-decoder-container')); \ No newline at end of file diff --git a/js/anchor-links.js b/js/anchor-links.js index 1b457f8962..c0b84a6785 100644 --- a/js/anchor-links.js +++ b/js/anchor-links.js @@ -1,5 +1,3 @@ -"use strict"; - // Add anchors to headings client-side, which prevents them from showing up // in RSS feeds. See https://github.com/facebook/react/issues/4124. (function () { diff --git a/js/errorMap.js b/js/errorMap.js index 924db31270..148b08724a 100644 --- a/js/errorMap.js +++ b/js/errorMap.js @@ -204,10 +204,10 @@ var errorMap = { "202": "ReactDOM.render(): Invalid component element. Instead of passing a class like Foo, pass React.createElement(Foo) or .", "203": "ReactDOM.render(): Invalid component element. This may be caused by unintentionally loading two independent copies of React.", "204": "ReactDOM.render(): Invalid component element.", - "205": "renderToStream(): Invalid component element.", - "206": "renderToStaticStream(): Invalid component element.", - "207": "ReactDOMServer.renderToStream(): The streaming API is not available in the browser. Use ReactDOMServer.renderToString() instead.", - "208": "ReactDOMServer.renderToStaticStream(): The streaming API is not available in the browser. Use ReactDOMServer.renderToStaticMarkup() instead.", + "205": "renderToNodeStream(): Invalid component element.", + "206": "renderToStaticNodeStream(): Invalid component element.", + "207": "ReactDOMServer.renderToNodeStream(): The streaming API is not available in the browser. Use ReactDOMServer.renderToString() instead.", + "208": "ReactDOMServer.renderToStaticNodeStream(): The streaming API is not available in the browser. Use ReactDOMServer.renderToStaticMarkup() instead.", "209": "renderToString(): Invalid component element.", "210": "renderToStaticMarkup(): Invalid component element.", "211": "Missing injection for fiber findDOMNode", @@ -232,5 +232,6 @@ var errorMap = { "230": "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.unstable_createPortal).", "231": "Expected `%s` listener to be a function, instead got a value of `%s` type.", "232": "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).", - "233": "Unsupported top level event type \"%s\" dispatched" + "233": "Unsupported top level event type \"%s\" dispatched", + "234": "Event cannot be both direct and bubbling: %s" }; diff --git a/js/examples/hello.js b/js/examples/hello.js index 71b5907b52..7372889f07 100644 --- a/js/examples/hello.js +++ b/js/examples/hello.js @@ -1,11 +1,4 @@ -'use strict'; - -var _jsxFileName = '_js/examples/hello.js'; var name = Math.random() > 0.5 ? 'Jane' : 'John'; var HELLO_COMPONENT = ('\nclass HelloMessage extends React.Component {\n render() {\n return
    Hello {this.props.name}
    ;\n }\n}\n\nReactDOM.render(, mountNode);\n').trim(); -ReactDOM.render(React.createElement(ReactPlayground, { codeText: HELLO_COMPONENT, __source: { - fileName: _jsxFileName, - lineNumber: 13 - } -}), document.getElementById('helloExample')); \ No newline at end of file +ReactDOM.render(React.createElement(ReactPlayground, { codeText: HELLO_COMPONENT }), document.getElementById('helloExample')); \ No newline at end of file diff --git a/js/examples/markdown.js b/js/examples/markdown.js index ddcac8a45b..4eb2e488da 100644 --- a/js/examples/markdown.js +++ b/js/examples/markdown.js @@ -1,10 +1,3 @@ -'use strict'; +var MARKDOWN_COMPONENT = '\nclass MarkdownEditor extends React.Component {\n constructor(props) {\n super(props);\n this.handleChange = this.handleChange.bind(this);\n this.state = {value: \'Type some *markdown* here!\'};\n }\n\n handleChange(e) {\n this.setState({value: e.target.value});\n }\n\n getRawMarkup() {\n var md = new Remarkable();\n return { __html: md.render(this.state.value) };\n }\n\n render() {\n return (\n
    \n

    Input

    \n \n

    Output

    \n \n
    \n );\n }\n}\n\nReactDOM.render(, mountNode);\n'.trim(); -var _jsxFileName = '_js/examples/markdown.js'; -var MARKDOWN_COMPONENT = '\nclass MarkdownEditor extends React.Component {\n constructor(props) {\n super(props);\n this.handleChange = this.handleChange.bind(this);\n this.state = {value: \'Type some *markdown* here!\'};\n }\n\n handleChange(e) {\n this.setState({value: e.target.value});\n }\n\n getRawMarkup() {\n var md = new Remarkable();\n return { __html: md.render(this.state.value) };\n }\n\n render() {\n return (\n
    \n

    Input

    \n \n

    Output

    \n \n
    \n );\n }\n}\n\nReactDOM.render(, mountNode);\n'.trim(); - -ReactDOM.render(React.createElement(ReactPlayground, { codeText: MARKDOWN_COMPONENT, __source: { - fileName: _jsxFileName, - lineNumber: 39 - } -}), document.getElementById('markdownExample')); \ No newline at end of file +ReactDOM.render(React.createElement(ReactPlayground, { codeText: MARKDOWN_COMPONENT }), document.getElementById('markdownExample')); \ No newline at end of file diff --git a/js/examples/timer.js b/js/examples/timer.js index cad8c36c7f..83093e501f 100644 --- a/js/examples/timer.js +++ b/js/examples/timer.js @@ -1,10 +1,3 @@ -'use strict'; - -var _jsxFileName = '_js/examples/timer.js'; var TIMER_COMPONENT = '\nclass Timer extends React.Component {\n constructor(props) {\n super(props);\n this.state = {secondsElapsed: 0};\n }\n\n tick() {\n this.setState((prevState) => ({\n secondsElapsed: prevState.secondsElapsed + 1\n }));\n }\n\n componentDidMount() {\n this.interval = setInterval(() => this.tick(), 1000);\n }\n\n componentWillUnmount() {\n clearInterval(this.interval);\n }\n\n render() {\n return (\n
    Seconds Elapsed: {this.state.secondsElapsed}
    \n );\n }\n}\n\nReactDOM.render(, mountNode);\n'.trim(); -ReactDOM.render(React.createElement(ReactPlayground, { codeText: TIMER_COMPONENT, __source: { - fileName: _jsxFileName, - lineNumber: 33 - } -}), document.getElementById('timerExample')); \ No newline at end of file +ReactDOM.render(React.createElement(ReactPlayground, { codeText: TIMER_COMPONENT }), document.getElementById('timerExample')); \ No newline at end of file diff --git a/js/examples/todo.js b/js/examples/todo.js index b02a13334f..03699187c8 100644 --- a/js/examples/todo.js +++ b/js/examples/todo.js @@ -1,10 +1,3 @@ -'use strict'; - -var _jsxFileName = '_js/examples/todo.js'; var TODO_COMPONENT = '\nclass TodoApp extends React.Component {\n constructor(props) {\n super(props);\n this.handleChange = this.handleChange.bind(this);\n this.handleSubmit = this.handleSubmit.bind(this);\n this.state = {items: [], text: \'\'};\n }\n\n render() {\n return (\n
    \n

    TODO

    \n \n
    \n \n \n
    \n
    \n );\n }\n\n handleChange(e) {\n this.setState({text: e.target.value});\n }\n\n handleSubmit(e) {\n e.preventDefault();\n var newItem = {\n text: this.state.text,\n id: Date.now()\n };\n this.setState((prevState) => ({\n items: prevState.items.concat(newItem),\n text: \'\'\n }));\n }\n}\n\nclass TodoList extends React.Component {\n render() {\n return (\n
      \n {this.props.items.map(item => (\n
    • {item.text}
    • \n ))}\n
    \n );\n }\n}\n\nReactDOM.render(, mountNode);\n'.trim(); -ReactDOM.render(React.createElement(ReactPlayground, { codeText: TODO_COMPONENT, __source: { - fileName: _jsxFileName, - lineNumber: 56 - } -}), document.getElementById('todoExample')); \ No newline at end of file +ReactDOM.render(React.createElement(ReactPlayground, { codeText: TODO_COMPONENT }), document.getElementById('todoExample')); \ No newline at end of file diff --git a/js/html-jsx-lib.js b/js/html-jsx-lib.js index 8f266c9981..75b1886c53 100644 --- a/js/html-jsx-lib.js +++ b/js/html-jsx-lib.js @@ -1,5 +1,3 @@ -'use strict'; - // Ideally it would be nice to just redirect, but GitHub Pages is very basic and // lacks that functionality. console.warn('html-jsx-lib.js has moved to http://reactjs.github.io/react-magic/' + 'htmltojsx.min.js. If using React-Magic, you are no longer required to ' + 'link to this file. Please delete its + @@ -63,7 +64,7 @@ diff --git a/tutorial/tutorial.html b/tutorial/tutorial.html index 8971ef05ee..a61c74469d 100644 --- a/tutorial/tutorial.html +++ b/tutorial/tutorial.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -1127,7 +1128,7 @@ // this method has not changed } -

    Then update stepNumber when a new move is made by adding stepNumber: history.length to the state update in Game's handleClick:

    +

    Then update stepNumber when a new move is made by adding stepNumber: history.length to the state update in Game's handleClick. We'll also update handleClick to be aware of stepNumber when reading the current board state so that you can go back in time then click in the board to create a new entry.:

      handleClick(i) {
         const history = this.state.history.slice(0, this.state.stepNumber + 1);
         const current = history[history.length - 1];
    @@ -1157,8 +1158,6 @@
     
     

    If you click any move link now, the board should immediately update to show what the game looked like at that time.

    -

    You may also want to update handleClick to be aware of stepNumber when reading the current board state so that you can go back in time then click in the board to create a new entry. (Hint: It's easiest to .slice() off the extra elements from history at the very top of handleClick.)

    -

    Wrapping Up

    Now, you've made a tic-tac-toe game that:

    diff --git a/warnings/dont-call-proptypes.html b/warnings/dont-call-proptypes.html index eb4fb56c01..f1d4077ebb 100644 --- a/warnings/dont-call-proptypes.html +++ b/warnings/dont-call-proptypes.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@
    @@ -88,7 +89,7 @@

    The normal usage of PropTypes is still supported:

    Button.propTypes = {
    -  highlighted: React.PropTypes.bool
    +  highlighted: PropTypes.bool
     };
     

    Nothing changes here.

    @@ -96,9 +97,9 @@

    Don’t call PropTypes directly

    Using PropTypes in any other way than annotating React components with them is no longer supported:

    -
    var apiShape = React.PropTypes.shape({
    -  body: React.PropTypes.object,
    -  statusCode: React.PropTypes.number.isRequired
    +
    var apiShape = PropTypes.shape({
    +  body: PropTypes.object,
    +  statusCode: PropTypes.number.isRequired
     }).isRequired;
     
     // Not supported!
    @@ -113,12 +114,12 @@
     

    Inspect the stack trace produced by the warning. You will find the component definition responsible for the PropTypes direct call. Most likely, the issue is due to third-party PropTypes that wrap React’s PropTypes, for example:

    Button.propTypes = {
       highlighted: ThirdPartyPropTypes.deprecated(
    -    React.PropTypes.bool,
    +    PropTypes.bool,
         'Use `active` prop instead'
       )
     }
     
    -

    In this case, ThirdPartyPropTypes.deprecated is a wrapper calling React.PropTypes.bool. This pattern by itself is fine, but triggers a false positive because React thinks you are calling PropTypes directly. The next section explains how to fix this problem for a library implementing something like ThirdPartyPropTypes. If it's not a library you wrote, you can file an issue against it.

    +

    In this case, ThirdPartyPropTypes.deprecated is a wrapper calling PropTypes.bool. This pattern by itself is fine, but triggers a false positive because React thinks you are calling PropTypes directly. The next section explains how to fix this problem for a library implementing something like ThirdPartyPropTypes. If it's not a library you wrote, you can file an issue against it.

    Fixing the false positive in third party PropTypes

    diff --git a/warnings/invalid-aria-prop.html b/warnings/invalid-aria-prop.html index 5a127977fa..767e3f7d21 100644 --- a/warnings/invalid-aria-prop.html +++ b/warnings/invalid-aria-prop.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@
    diff --git a/warnings/legacy-factories.html b/warnings/legacy-factories.html index 23134a53cf..f4ac563fa1 100644 --- a/warnings/legacy-factories.html +++ b/warnings/legacy-factories.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ diff --git a/warnings/refs-must-have-owner.html b/warnings/refs-must-have-owner.html index 43168fa0ad..44142d500f 100644 --- a/warnings/refs-must-have-owner.html +++ b/warnings/refs-must-have-owner.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@ @@ -74,7 +75,17 @@

    Refs Must Have Owner Warning

    -

    You are probably here because you got the following error messages:

    +

    You are probably here because you got one of the following error messages:

    + +

    React 16.0.0+

    + +
    +

    Warning:

    + +

    Element ref was specified as a string (myRefName) but no owner was set. You may have multiple copies of React loaded. (details: https://fb.me/react-refs-must-have-owner).

    +
    + +

    earlier versions of React

    Warning:

    diff --git a/warnings/special-props.html b/warnings/special-props.html index 04636f1abd..c1c10160bf 100644 --- a/warnings/special-props.html +++ b/warnings/special-props.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@
    diff --git a/warnings/unknown-prop.html b/warnings/unknown-prop.html index f5cf17995d..1d6b5e398b 100644 --- a/warnings/unknown-prop.html +++ b/warnings/unknown-prop.html @@ -36,6 +36,7 @@ + @@ -63,7 +64,7 @@