diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000000..774c6cec66 --- /dev/null +++ b/circle.yml @@ -0,0 +1,5 @@ +--- +general: + branches: + ignore: + - gh-pages diff --git a/docs/react-component.html b/docs/react-component.html index 80195aa020..df9cb2eb23 100644 --- a/docs/react-component.html +++ b/docs/react-component.html @@ -286,14 +286,14 @@

setState() will always lead to a re-render unless shouldComponentUpdate() returns false. If mutable objects are being used and conditional rendering logic cannot be implemented in shouldComponentUpdate(), calling setState() only when the new state differs from the previous state will avoid unnecessary re-renders.

The first argument is an updater function with the signature:

-
(prevState, props) => nextState
+
(prevState, props) => stateChange
 
-

prevState is a reference to the previous state. It should not be directly mutated. Instead, changes should be represented by building a new state object based on the input from prevState and props. For instance, suppose we wanted to increment a value in state by props.step:

+

prevState is a reference to the previous state. It should not be directly mutated. Instead, changes should be represented by building a new object based on the input from prevState and props. For instance, suppose we wanted to increment a value in state by props.step:

this.setState((prevState, props) => {
   return {counter: prevState.counter + props.step};
 });
 
-

Both prevState and props received by the updater function are guaranteed to be up-to-date.

+

Both prevState and props received by the updater function are guaranteed to be up-to-date. The output of the updater is shallowly merged with prevState.

The second parameter to setState() is an optional callback function that will be executed once setState is completed and the component is re-rendered. Generally we recommend using componentDidUpdate() for such logic instead.

diff --git a/js/ErrorDecoderComponent.js b/js/ErrorDecoderComponent.js index c0aafab90f..ad46a7e7e6 100644 --- a/js/ErrorDecoderComponent.js +++ b/js/ErrorDecoderComponent.js @@ -9,6 +9,8 @@ /* 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,7 +34,11 @@ function urlify(str) { if (i % 2 === 1) { segments[i] = React.createElement( 'a', - { key: i, target: '_blank', href: segments[i] }, + { key: i, target: '_blank', href: segments[i], __source: { + fileName: _jsxFileName, + lineNumber: 27 + } + }, segments[i] ); } @@ -71,22 +77,42 @@ function ErrorResult(props) { if (!code) { return React.createElement( 'p', - null, + { + __source: { + fileName: _jsxFileName, + lineNumber: 63 + } + }, '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', - null, + { + __source: { + fileName: _jsxFileName, + lineNumber: 68 + } + }, React.createElement( 'p', - null, + { + __source: { + fileName: _jsxFileName, + lineNumber: 69 + } + }, 'The full text of the error you just encountered is:' ), React.createElement( 'code', - null, + { + __source: { + fileName: _jsxFileName, + lineNumber: 70 + } + }, urlify(errorMsg) ) ); @@ -129,11 +155,20 @@ var ErrorDecoder = function (_React$Component) { ErrorDecoder.prototype.render = function render() { return React.createElement(ErrorResult, { code: this.state.code, - msg: this.state.errorMsg + msg: this.state.errorMsg, + __source: { + fileName: _jsxFileName, + lineNumber: 100 + } }); }; return ErrorDecoder; }(React.Component); -ReactDOM.render(React.createElement(ErrorDecoder, null), document.querySelector('.error-decoder-container')); \ No newline at end of file +ReactDOM.render(React.createElement(ErrorDecoder, { + __source: { + fileName: _jsxFileName, + lineNumber: 109 + } +}), document.querySelector('.error-decoder-container')); \ No newline at end of file diff --git a/js/anchor-links.js b/js/anchor-links.js index c0b84a6785..1b457f8962 100644 --- a/js/anchor-links.js +++ b/js/anchor-links.js @@ -1,3 +1,5 @@ +"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/examples/hello.js b/js/examples/hello.js index 7372889f07..71b5907b52 100644 --- a/js/examples/hello.js +++ b/js/examples/hello.js @@ -1,4 +1,11 @@ +'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 }), document.getElementById('helloExample')); \ No newline at end of file +ReactDOM.render(React.createElement(ReactPlayground, { codeText: HELLO_COMPONENT, __source: { + fileName: _jsxFileName, + lineNumber: 13 + } +}), document.getElementById('helloExample')); \ No newline at end of file diff --git a/js/examples/markdown.js b/js/examples/markdown.js index 237a0cb256..ddcac8a45b 100644 --- a/js/examples/markdown.js +++ b/js/examples/markdown.js @@ -1,3 +1,10 @@ +'use strict'; + +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 }), document.getElementById('markdownExample')); \ No newline at end of file +ReactDOM.render(React.createElement(ReactPlayground, { codeText: MARKDOWN_COMPONENT, __source: { + fileName: _jsxFileName, + lineNumber: 39 + } +}), document.getElementById('markdownExample')); \ No newline at end of file diff --git a/js/examples/timer.js b/js/examples/timer.js index 83093e501f..cad8c36c7f 100644 --- a/js/examples/timer.js +++ b/js/examples/timer.js @@ -1,3 +1,10 @@ +'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 }), document.getElementById('timerExample')); \ No newline at end of file +ReactDOM.render(React.createElement(ReactPlayground, { codeText: TIMER_COMPONENT, __source: { + fileName: _jsxFileName, + lineNumber: 33 + } +}), document.getElementById('timerExample')); \ No newline at end of file diff --git a/js/examples/todo.js b/js/examples/todo.js index 03699187c8..b02a13334f 100644 --- a/js/examples/todo.js +++ b/js/examples/todo.js @@ -1,3 +1,10 @@ +'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 }), document.getElementById('todoExample')); \ No newline at end of file +ReactDOM.render(React.createElement(ReactPlayground, { codeText: TODO_COMPONENT, __source: { + fileName: _jsxFileName, + lineNumber: 56 + } +}), document.getElementById('todoExample')); \ No newline at end of file diff --git a/js/html-jsx-lib.js b/js/html-jsx-lib.js index 1d256e11e3..fa697b7bb4 100644 --- a/js/html-jsx-lib.js +++ b/js/html-jsx-lib.js @@ -1,3 +1,5 @@ +'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