diff --git a/.babelrc b/.babelrc old mode 100644 new mode 100755 diff --git a/.circleci/config.yml b/.circleci/config.yml old mode 100644 new mode 100755 diff --git a/.eslintignore b/.eslintignore old mode 100644 new mode 100755 diff --git a/.eslintrc b/.eslintrc old mode 100644 new mode 100755 diff --git a/.flowconfig b/.flowconfig old mode 100644 new mode 100755 diff --git a/.gitattributes b/.gitattributes old mode 100644 new mode 100755 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.nvmrc b/.nvmrc old mode 100644 new mode 100755 diff --git a/.prettierrc b/.prettierrc old mode 100644 new mode 100755 diff --git a/README.md b/README.md index bc31db6083..db43b3bfb7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# React 中文文档翻译计划 +# React 中文文档翻译计划 ![CircleCI](https://circleci.com/gh/discountry/react.svg?&style=shield&circle-token=4fc9b6b97cb8d5d19ad88cdd40ba8d5f1ccdd2b0) ## Notice diff --git a/README_en.md b/README_en.md old mode 100644 new mode 100755 diff --git a/content/404.md b/content/404.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-06-02-jsfiddle-integration.md b/content/blog/2013-06-02-jsfiddle-integration.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-06-05-why-react.md b/content/blog/2013-06-05-why-react.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-06-12-community-roundup.md b/content/blog/2013-06-12-community-roundup.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-06-19-community-roundup-2.md b/content/blog/2013-06-19-community-roundup-2.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-06-21-react-v0-3-3.md b/content/blog/2013-06-21-react-v0-3-3.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-06-27-community-roundup-3.md b/content/blog/2013-06-27-community-roundup-3.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-07-02-react-v0-4-autobind-by-default.md b/content/blog/2013-07-02-react-v0-4-autobind-by-default.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-07-03-community-roundup-4.md b/content/blog/2013-07-03-community-roundup-4.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-07-11-react-v0-4-prop-validation-and-default-values.md b/content/blog/2013-07-11-react-v0-4-prop-validation-and-default-values.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-07-17-react-v0-4-0.md b/content/blog/2013-07-17-react-v0-4-0.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-07-23-community-roundup-5.md b/content/blog/2013-07-23-community-roundup-5.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-07-26-react-v0-4-1.md b/content/blog/2013-07-26-react-v0-4-1.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-07-30-use-react-and-jsx-in-ruby-on-rails.md b/content/blog/2013-07-30-use-react-and-jsx-in-ruby-on-rails.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-08-05-community-roundup-6.md b/content/blog/2013-08-05-community-roundup-6.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-08-19-use-react-and-jsx-in-python-applications.md b/content/blog/2013-08-19-use-react-and-jsx-in-python-applications.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-08-26-community-roundup-7.md b/content/blog/2013-08-26-community-roundup-7.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-09-24-community-roundup-8.md b/content/blog/2013-09-24-community-roundup-8.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-10-16-react-v0.5.0.md b/content/blog/2013-10-16-react-v0.5.0.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-10-29-react-v0-5-1.md b/content/blog/2013-10-29-react-v0-5-1.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-10-3-community-roundup-9.md b/content/blog/2013-10-3-community-roundup-9.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-11-06-community-roundup-10.md b/content/blog/2013-11-06-community-roundup-10.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-11-18-community-roundup-11.md b/content/blog/2013-11-18-community-roundup-11.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-12-18-react-v0.5.2-v0.4.2.md b/content/blog/2013-12-18-react-v0.5.2-v0.4.2.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-12-19-react-v0.8.0.md b/content/blog/2013-12-19-react-v0.8.0.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-12-23-community-roundup-12.md b/content/blog/2013-12-23-community-roundup-12.md old mode 100644 new mode 100755 diff --git a/content/blog/2013-12-30-community-roundup-13.md b/content/blog/2013-12-30-community-roundup-13.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-01-02-react-chrome-developer-tools.md b/content/blog/2014-01-02-react-chrome-developer-tools.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-01-06-community-roundup-14.md b/content/blog/2014-01-06-community-roundup-14.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-02-05-community-roundup-15.md b/content/blog/2014-02-05-community-roundup-15.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-02-15-community-roundup-16.md b/content/blog/2014-02-15-community-roundup-16.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-02-16-react-v0.9-rc1.md b/content/blog/2014-02-16-react-v0.9-rc1.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-02-20-react-v0.9.md b/content/blog/2014-02-20-react-v0.9.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-02-24-community-roundup-17.md b/content/blog/2014-02-24-community-roundup-17.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-03-14-community-roundup-18.md b/content/blog/2014-03-14-community-roundup-18.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-03-19-react-v0.10-rc1.md b/content/blog/2014-03-19-react-v0.10-rc1.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-03-21-react-v0.10.md b/content/blog/2014-03-21-react-v0.10.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-03-28-the-road-to-1.0.md b/content/blog/2014-03-28-the-road-to-1.0.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-04-04-reactnet.md b/content/blog/2014-04-04-reactnet.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-05-06-flux.md b/content/blog/2014-05-06-flux.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-05-29-one-year-of-open-source-react.md b/content/blog/2014-05-29-one-year-of-open-source-react.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-06-27-community-roundup-19.md b/content/blog/2014-06-27-community-roundup-19.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-07-13-react-v0.11-rc1.md b/content/blog/2014-07-13-react-v0.11-rc1.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-07-17-react-v0.11.md b/content/blog/2014-07-17-react-v0.11.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-07-25-react-v0.11.1.md b/content/blog/2014-07-25-react-v0.11.1.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-07-28-community-roundup-20.md b/content/blog/2014-07-28-community-roundup-20.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-07-30-flux-actions-and-the-dispatcher.md b/content/blog/2014-07-30-flux-actions-and-the-dispatcher.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-08-03-community-roundup-21.md b/content/blog/2014-08-03-community-roundup-21.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-09-03-introducing-the-jsx-specification.md b/content/blog/2014-09-03-introducing-the-jsx-specification.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-09-12-community-round-up-22.md b/content/blog/2014-09-12-community-round-up-22.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-09-16-react-v0.11.2.md b/content/blog/2014-09-16-react-v0.11.2.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-09-24-testing-flux-applications.md b/content/blog/2014-09-24-testing-flux-applications.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-10-14-introducing-react-elements.md b/content/blog/2014-10-14-introducing-react-elements.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-10-16-react-v0.12-rc1.md b/content/blog/2014-10-16-react-v0.12-rc1.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-10-17-community-roundup-23.md b/content/blog/2014-10-17-community-roundup-23.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-10-27-react-js-conf.md b/content/blog/2014-10-27-react-js-conf.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-10-28-react-v0.12.md b/content/blog/2014-10-28-react-v0.12.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-11-24-react-js-conf-updates.md b/content/blog/2014-11-24-react-js-conf-updates.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-11-25-community-roundup-24.md b/content/blog/2014-11-25-community-roundup-24.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-12-18-react-v0.12.2.md b/content/blog/2014-12-18-react-v0.12.2.md old mode 100644 new mode 100755 diff --git a/content/blog/2014-12-19-react-js-conf-diversity-scholarship.md b/content/blog/2014-12-19-react-js-conf-diversity-scholarship.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-01-27-react-v0.13.0-beta-1.md b/content/blog/2015-01-27-react-v0.13.0-beta-1.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-02-18-react-conf-roundup-2015.md b/content/blog/2015-02-18-react-conf-roundup-2015.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-02-20-introducing-relay-and-graphql.md b/content/blog/2015-02-20-introducing-relay-and-graphql.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-02-24-react-v0.13-rc1.md b/content/blog/2015-02-24-react-v0.13-rc1.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-02-24-streamlining-react-elements.md b/content/blog/2015-02-24-streamlining-react-elements.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-03-03-react-v0.13-rc2.md b/content/blog/2015-03-03-react-v0.13-rc2.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-03-04-community-roundup-25.md b/content/blog/2015-03-04-community-roundup-25.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-03-10-react-v0.13.md b/content/blog/2015-03-10-react-v0.13.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-03-16-react-v0.13.1.md b/content/blog/2015-03-16-react-v0.13.1.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-03-19-building-the-facebook-news-feed-with-relay.md b/content/blog/2015-03-19-building-the-facebook-news-feed-with-relay.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-03-26-introducing-react-native.md b/content/blog/2015-03-26-introducing-react-native.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-03-30-community-roundup-26.md b/content/blog/2015-03-30-community-roundup-26.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-04-17-react-native-v0.4.md b/content/blog/2015-04-17-react-native-v0.4.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-04-18-react-v0.13.2.md b/content/blog/2015-04-18-react-v0.13.2.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-05-01-graphql-introduction.md b/content/blog/2015-05-01-graphql-introduction.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-05-08-react-v0.13.3.md b/content/blog/2015-05-08-react-v0.13.3.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-05-22-react-native-release-process.md b/content/blog/2015-05-22-react-native-release-process.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-06-12-deprecating-jstransform-and-react-tools.md b/content/blog/2015-06-12-deprecating-jstransform-and-react-tools.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-07-03-react-v0.14-beta-1.md b/content/blog/2015-07-03-react-v0.14-beta-1.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-08-03-new-react-devtools-beta.md b/content/blog/2015-08-03-new-react-devtools-beta.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-08-11-relay-technical-preview.md b/content/blog/2015-08-11-relay-technical-preview.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-08-13-reacteurope-roundup.md b/content/blog/2015-08-13-reacteurope-roundup.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-09-02-new-react-developer-tools.md b/content/blog/2015-09-02-new-react-developer-tools.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-09-10-react-v0.14-rc1.md b/content/blog/2015-09-10-react-v0.14-rc1.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-09-14-community-roundup-27.md b/content/blog/2015-09-14-community-roundup-27.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-10-01-react-render-and-top-level-api.md b/content/blog/2015-10-01-react-render-and-top-level-api.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-10-07-react-v0.14.md b/content/blog/2015-10-07-react-v0.14.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-10-19-reactiflux-is-moving-to-discord.md b/content/blog/2015-10-19-reactiflux-is-moving-to-discord.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-10-28-react-v0.14.1.md b/content/blog/2015-10-28-react-v0.14.1.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-11-02-react-v0.14.2.md b/content/blog/2015-11-02-react-v0.14.2.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-11-18-react-v0.14.3.md b/content/blog/2015-11-18-react-v0.14.3.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-12-04-react-js-conf-2016-diversity-scholarship.md b/content/blog/2015-12-04-react-js-conf-2016-diversity-scholarship.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-12-16-ismounted-antipattern.md b/content/blog/2015-12-16-ismounted-antipattern.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-12-18-react-components-elements-and-instances.md b/content/blog/2015-12-18-react-components-elements-and-instances.md old mode 100644 new mode 100755 diff --git a/content/blog/2015-12-29-react-v0.14.4.md b/content/blog/2015-12-29-react-v0.14.4.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-01-08-A-implies-B-does-not-imply-B-implies-A.md b/content/blog/2016-01-08-A-implies-B-does-not-imply-B-implies-A.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-01-12-discontinuing-ie8-support.md b/content/blog/2016-01-12-discontinuing-ie8-support.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-02-19-new-versioning-scheme.md b/content/blog/2016-02-19-new-versioning-scheme.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-03-07-react-v15-rc1.md b/content/blog/2016-03-07-react-v15-rc1.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-03-16-react-v15-rc2.md b/content/blog/2016-03-16-react-v15-rc2.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-03-29-react-v0.14.8.md b/content/blog/2016-03-29-react-v0.14.8.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-04-07-react-v15.md b/content/blog/2016-04-07-react-v15.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-04-08-react-v15.0.1.md b/content/blog/2016-04-08-react-v15.0.1.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-07-11-introducing-reacts-error-code-system.md b/content/blog/2016-07-11-introducing-reacts-error-code-system.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-07-13-mixins-considered-harmful.md b/content/blog/2016-07-13-mixins-considered-harmful.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-07-22-create-apps-with-no-configuration.md b/content/blog/2016-07-22-create-apps-with-no-configuration.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-08-05-relay-state-of-the-state.md b/content/blog/2016-08-05-relay-state-of-the-state.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-09-28-our-first-50000-stars.md b/content/blog/2016-09-28-our-first-50000-stars.md old mode 100644 new mode 100755 diff --git a/content/blog/2016-11-16-react-v15.4.0.md b/content/blog/2016-11-16-react-v15.4.0.md old mode 100644 new mode 100755 diff --git a/content/blog/2017-04-07-react-v15.5.0.md b/content/blog/2017-04-07-react-v15.5.0.md old mode 100644 new mode 100755 index 943e1b572c..f901fadae6 --- a/content/blog/2017-04-07-react-v15.5.0.md +++ b/content/blog/2017-04-07-react-v15.5.0.md @@ -7,7 +7,7 @@ author: [acdlite] 最后,我们发布了React 15.5.0。 -### 新的弃用警告 {#new-deprecation-warnings} +### 新的弃用警告 最大的改变是我们将`React.PropTypes`和`React.createClass` 移到他们的自己的包。二者仍然可以通过主要的`React`独享访问,但是在开发模式下,使用其中的一个将在控制台上打印一个过时的弃用警告。这将会让之后代码大小有所优化。 @@ -19,7 +19,7 @@ author: [acdlite] 关于每一项新的弃用,我们已经提供了一份代码修改(codemod)以自动迁移你的代码。它们已可以利用来作为 [react-codemod](https://github.com/reactjs/react-codemod)项目的部分。 -### 从 React.PropTypes 迁移 {#migrating-from-reactproptypes} +### 从React.PropTypes迁移 属性类型是用于在开发期间对属性进行运行时校验的一项特性。我们已将内建的属性类型提取到一个独立的包中以反映是否并非每个人都会使用的事实。 @@ -64,7 +64,7 @@ jscodeshift -t react-codemod/transforms/React-PropTypes-to-prop-types.js 你也可能考虑使用 [Flow](https://flow.org/)来静态地检查你的JavaScript代码类型,包括[React 组件](https://flow.org/en/docs/frameworks/react/#setup-flow-with-react-a-classtoc-idtoc-setup-flow-with-react-hreftoc-setup-flow-with-reacta). -### 从 React.crateClass 迁移 {#migrating-from-reactcreateclass} +### 从React.crateClass迁移 当React首次发布时,在JavaScript中并没有通用的方式创建类,因此我们提供我们一个自定义方法:`React.createClass`。 @@ -105,7 +105,7 @@ var Component = createReactClass({ jscodeshift -t react-codemod/transforms/class.js path/to/components ``` -### 不再支持的 React 附件 {#discontinuing-support-for-react-addons} +### 不再支持的React附件 我们将停止维护React附件包。真实地,大多数包已经有很长时间没有维护了。它们仍将持续继续工作,但我们建议尽快迁移以防止将来的破坏。 @@ -120,7 +120,7 @@ jscodeshift -t react-codemod/transforms/class.js path/to/components 我们也放弃对于`react-with-addons`UMD构建的支持。其将在React 16中被移除。 -### React 测试套件 {#react-test-utils} +### React测试套件 当前,React 测试套件位于`react-addons-test-utils`内。在15.5中,我们将其从包中独立出去,并将它们迁移至`react-dom/test-utils`: @@ -146,7 +146,7 @@ import { createRenderer } from 'react-test-renderer/shallow'; --- -## 感谢 {#acknowledgements} +## 感谢 特别感谢这些人转让npm包名称的所有权: @@ -156,7 +156,7 @@ import { createRenderer } from 'react-test-renderer/shallow'; --- -## 安装 {#installation} +## 安装 我们推荐使用[Yarn](https://yarnpkg.com/)或[npm](https://www.npmjs.com/)来管理前端依赖。若你是初次接触包管理器,[Yarn documentation](https://yarnpkg.com/en/docs/getting-started)是一个不错的起点。 @@ -195,11 +195,11 @@ npm install --save react@^15.5.0 react-dom@^15.5.0 --- -## 修改日志 {#changelog} +## 修改日志 -## 15.5.0 (April 7, 2017) {#1550-april-7-2017} +## 15.5.0 (April 7, 2017) -### React {#react} +### React * 为`React.createClass`增加一个独立的警告。将用户指向create-react-class。([@acdlite](https://github.com/acdlite) 在 [d9a4fa4](https://github.com/facebook/react/commit/d9a4fa4f51c6da895e1655f32255cf72c0fe620e)的提交) * 为`React.PropTypes`增加一个独立的警告。将用户指向prop-types。([@acdlite](https://github.com/acdlite) 在 [043845c](https://github.com/facebook/react/commit/043845ce75ea0812286bbbd9d34994bb7e01eb28)的提交) @@ -208,17 +208,17 @@ npm install --save react@^15.5.0 react-dom@^15.5.0 * 另一个关于Closure Compiler的修复。([@Shastel](https://github.com/Shastel) 在 [#8882](https://github.com/facebook/react/pull/8882)提的PR) * 为无效的元素类型警告增加组件栈信息。([@n3tr](https://github.com/n3tr) 在 [#8495](https://github.com/facebook/react/pull/8495)提的PR) -### React DOM {#react-dom} +### React DOM * 修正当在数字输入中回退时的Chrome bug。([@nhunzaker](https://github.com/nhunzaker) 在 [#7359](https://github.com/facebook/react/pull/7359)提的PR) * 增加`react-dom/test-utils`,暴露React测试套件。([@bvaughn](https://github.com/bvaughn)) -### React Test Renderer {#react-test-renderer} +### React Test Renderer * 修复子组件不会调用`componentWillUnmount`。([@gre](https://github.com/gre) 在 [#8512](https://github.com/facebook/react/pull/8512]提的PR) * 增加 `react-test-renderer/shallow`,暴露浅渲染器。 -### React Addons {#react-addons} +### React Addons * 最后一次发布附件;他们将不再被维护 * 移除`peerDependencies`以让附件能够无限期继续工作。([@acdlite](https://github.com/acdlite) 和 [@bvaughn](https://github.com/bvaughn) 在 [8a06cd7](https://github.com/facebook/react/commit/8a06cd7a786822fce229197cac8125a551e8abfa) 和 [67a8db3](https://github.com/facebook/react/commit/67a8db3650d724a51e70be130e9008806402678a)的提交) diff --git a/content/blog/2017-05-18-whats-new-in-create-react-app.md b/content/blog/2017-05-18-whats-new-in-create-react-app.md old mode 100644 new mode 100755 index bbbd39a4e2..c7664133aa --- a/content/blog/2017-05-18-whats-new-in-create-react-app.md +++ b/content/blog/2017-05-18-whats-new-in-create-react-app.md @@ -11,7 +11,7 @@ author: [gaearon] 新创建的项目会自动获得这些新的功能改进。 -### webpack 2 {#webpack-2} +### webpack 2 >*这个功能开发者是[@Timer](https://github.com/Timer) 在 [#1291](https://github.com/facebookincubator/create-react-app/pull/1291).* @@ -27,7 +27,7 @@ webpack 2 最引人注目的新特性就是其对 ES6 模块 的支持,可以 未来,随着 ES6 模块相关生态系统的成熟,webpack 2 还提供了 [tree shaking](https://webpack.js.org/guides/tree-shaking/) 特性,可以通过去除冗余代码,优化打包后脚本的尺寸。 -### Runtime Error Overlay {#error-overlay} +### Runtime Error Overlay >*开发这个功能的是 [@Timer](https://github.com/Timer) 和 [@nicinabox](https://github.com/nicinabox) 在 [#1101](https://github.com/facebookincubator/create-react-app/pull/1101), [@bvaughn](https://github.com/bvaughn) 在 [#2201](https://github.com/facebookincubator/create-react-app/pull/2201).* @@ -43,7 +43,7 @@ webpack 2 最引人注目的新特性就是其对 ES6 模块 的支持,可以 未来 Creat React App 还准备支持更多错误捕获。比如在React 16 版本发布之后,Creat React App 计划支持 React 组件调用栈的展示。 -### 默认支持渐进式 web 应用 {#progressive-web-apps-by-default} +### 默认支持渐进式web应用 >*这个功能的贡献者是 [@jeffposnick](https://github.com/jeffposnick) 在 [#1728](https://github.com/facebookincubator/create-react-app/pull/1728).* @@ -56,7 +56,7 @@ webpack 2 最引人注目的新特性就是其对 ES6 模块 的支持,可以 在未来的几周我们会为这个主题增加 [更多文档](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app)。希望大家在答疑区畅所欲言,[积极提问](https://github.com/facebookincubator/create-react-app/issues/new) 。 -### Jest 20 {#jest-20} +### Jest 20 >*这个功能的贡献者是 [@rogeliog](https://github.com/rogeliog) 在 [#1614](https://github.com/facebookincubator/create-react-app/pull/1614) 和 [@gaearon](https://github.com/gaearon) 在 [#2171](https://github.com/facebookincubator/create-react-app/pull/2171).* @@ -68,7 +68,7 @@ webpack 2 最引人注目的新特性就是其对 ES6 模块 的支持,可以 现在 Create React App 只需要做少量 Jest 的配置就可以生成覆盖率报告了。 -### 动态 import() 代码分割 {#code-splitting-with-dynamic-import} +### 动态import()代码分割 >*这个功能的贡献者是 [@Timer](https://github.com/Timer) 在 [#1538](https://github.com/facebookincubator/create-react-app/pull/1538) 和 [@tharakawj](https://github.com/tharakawj) 在 [#1801](https://github.com/facebookincubator/create-react-app/pull/1801).* @@ -78,7 +78,7 @@ webpack 2 最引人注目的新特性就是其对 ES6 模块 的支持,可以 ![Creating chunks with dynamic import](../img/blog/cra-dynamic-import.gif) -### 更好的控制台输出 {#better-console-output} +### 更好的控制台输出 >*本功能开发者是 [@gaearon](https://github.com/gaearon) 于 [#2120](https://github.com/facebookincubator/create-react-app/pull/2120), [#2125](https://github.com/facebookincubator/create-react-app/pull/2125), 和 [#2161](https://github.com/facebookincubator/create-react-app/pull/2161)。* @@ -90,13 +90,13 @@ webpack 2 最引人注目的新特性就是其对 ES6 模块 的支持,可以 当代码错误报告出来了,我们将不再展示警告信息以便你集中注意力到更严重的问题上。错误和警告信息在生产环境下的展示也被优化了,而且构建错误的弹出字体跟浏览器字体匹配度更高了。 -### 别急... 还有干货! {#but-wait-theres-more} +### 别急... 还有干货! 虽然讲了很多,但是这个版本中还有许多未能介绍的新特性,比如 [environment-specific and local `.env` files](https://github.com/facebookincubator/create-react-app/pull/1344),[a lint rule against confusingly named globals](https://github.com/facebookincubator/create-react-app/pull/2130),[support for multiple proxies in development](https://github.com/facebookincubator/create-react-app/pull/1790), [a customizable browser launch script](https://github.com/facebookincubator/create-react-app/pull/1590)以及许多 bug 修复。 更多信息请参阅升级文档 [v1.0.0 发布详情](https://github.com/facebookincubator/create-react-app/releases/tag/v1.0.0)。 -### 致谢 {#acknowledgements} +### 致谢 这个发布版本是 React 社区的许多成员共同奋斗几个月的成果。我们旨在同时提升开发者的开发体验和用户的使用体验,因为我们坚信,这二者是互相补充携手并进的。 diff --git a/content/blog/2017-06-13-react-v15.6.0.md b/content/blog/2017-06-13-react-v15.6.0.md old mode 100644 new mode 100755 index 5bd3c90945..0769fbd6f0 --- a/content/blog/2017-06-13-react-v15.6.0.md +++ b/content/blog/2017-06-13-react-v15.6.0.md @@ -5,7 +5,7 @@ author: [flarnie] 今天我们发布了 React 15.6.0。由于我们在准备React 16.0,因此我们修复和清理了许多东西。此次发布将继续为后续铺路。 -## 提升Inputs {#improving-inputs} +## 提升Inputs 在React 15.6.0,输入框的`onChange`事件稍微可靠了点并能够处理更多边界条件,涵盖以下: @@ -18,7 +18,7 @@ author: [flarnie] 感谢[Jason Quense](https://github.com/jquense)以及其他帮助解决上述问题和提出PR的各位。 -## 更少嘈杂的弃用警告 {#less-noisy-deprecation-warnings} +## 更少嘈杂的弃用警告 我们还为之后的弃用引入了一系列新的警告。这些并不会影响大多数用户,更多细节可以查看下面的修改日志。 @@ -26,7 +26,7 @@ author: [flarnie] --- -## 安装 {#installation} +## 安装 我们推荐使用 [Yarn](https://yarnpkg.com/) 或 [npm](https://www.npmjs.com/) 来管理前端依赖。若你是初次接触包管理器,[Yarn 文档](https://yarnpkg.com/en/docs/getting-started)是一个不错的起点。 @@ -65,18 +65,18 @@ npm install --save react@^15.6.0 react-dom@^15.6.0 ------------ -## 修改日志 {#changelog} +## 修改日志 -## 15.6.0 (June 13, 2017) {#1560-june-13-2017} +## 15.6.0 (June 13, 2017) -### React {#react} +### React * 采用`console.warn`而不是`console.error`来降级处理弃用警告。([@flarnie](https://github.com/flarnie) 在 [#9753](https://github.com/facebook/react/pull/9753) 的提交) * 为`React.createClass`增加弃用警告。将用户指向`create-react-class`。([@flarnie](https://github.com/flarnie) 在 [#9771](https://github.com/facebook/react/pull/9771) 的提交) * 增加弃用警告并为`React.DOM`工厂辅助方法分离为新模块。([@nhunzaker](https://github.com/nhunzaker) 在 [#8356](https://github.com/facebook/react/pull/8356) 的提交) * `React.createMixin`的弃用警告辅助方法将不再使用。([@aweary](https://github.com/aweary) 在 [#8853](https://github.com/facebook/react/pull/8853) 的提交) -### React DOM {#react-dom} +### React DOM * 在`style`属性中增加CSS变量支持。 ([@aweary](https://github.com/aweary) 在 [#9302](https://github.com/facebook/react/pull/9302) 的提交) * 增加CSS网格(Grid)样式属性支持。([@ericsakmar](https://github.com/ericsakmar) 在 [#9185](https://github.com/facebook/react/pull/9185) 的提交) @@ -84,12 +84,3 @@ npm install --save react@^15.6.0 react-dom@^15.6.0 * 修复在某些输入场景下`onChange`未触发的问题。([@jquense](https://github.com/jquense) 在 [#8575](https://github.com/facebook/react/pull/8575) 的提交) * 修复控制数字输入框错误允许期间的异常。([@nhunzaker](https://github.com/nhunzaker) 在 [#9584](https://github.com/facebook/react/pull/9584) 的提交) * 修复性能记录(performance entry)被清除的bug。([@chrisui](https://github.com/chrisui) 在 [#9451](https://github.com/facebook/react/pull/9451) 的提交) - -### React Addons {#react-addons} - -* Fix AMD support for addons depending on `react`. ([@flarnie](https://github.com/flarnie) in [#9919](https://github.com/facebook/react/issues/9919)) -* Fix `isMounted()` to return `true` in `componentWillUnmount`. ([@mridgway](https://github.com/mridgway) in [#9638](https://github.com/facebook/react/issues/9638)) -* Fix `react-addons-update` to not depend on native `Object.assign`. ([@gaearon](https://github.com/gaearon) in [#9937](https://github.com/facebook/react/pull/9937)) -* Remove broken Google Closure Compiler annotation from `create-react-class`. ([@gaearon](https://github.com/gaearon) in [#9933](https://github.com/facebook/react/pull/9933)) -* Remove unnecessary dependency from `react-linked-input`. ([@gaearon](https://github.com/gaearon) in [#9766](https://github.com/facebook/react/pull/9766)) -* Point `react-addons-(css-)transition-group` to the new package. ([@gaearon](https://github.com/gaearon) in [#9937](https://github.com/facebook/react/pull/9937)) diff --git a/content/blog/2017-07-26-error-handle-in-react-16.md b/content/blog/2017-07-26-error-handle-in-react-16.md new file mode 100755 index 0000000000..c742295bd3 --- /dev/null +++ b/content/blog/2017-07-26-error-handle-in-react-16.md @@ -0,0 +1,116 @@ +--- +title: "Error Handle in React 16" +author: [gaearon] +--- + +随着React 16发布在即,我们打算介绍一些在组件内部React如何处理JavaScript错误。这些改变包含在React 16的beta版本中,并将成为React 16的一部分。 + +**顺便一提,[你可以尝试我们刚发布了React 16的第一个测试版本!](https://github.com/facebook/react/issues/10294)** + +## React 15及之前的行为 + +过去,组件内部的JavaScript异常曾经常阻断了React内部状态并导致其在下一次渲染时[触发了隐藏的错误](https://github.com/facebook/react/issues/6895)。这些错误常常是由应用程序代码中的早期错误所引起的,但React并未提供一种在组件里优雅处理的方式,也不会从异常中回复。 + +## 错误边界介绍 + +UI部分的JavaScript异常不应阻断整个应用。为了为React用户解决这一问题,React 16引入了"错误边界(error boundary")"这一新概念。 + +错误边界作为React组件,用以**捕获在子组件树种任何地方的JavaScript异常,打印这些错误,并展示备用UI**而非让组件树崩溃。错误边界会捕获渲染期间,在生命周期方法中以及在其整个树的构造函数中的异常。 + +若定义一个称为`componentDidCatch(error, info)`的新生命周期方法,则类组件将成为错误边界: + +```javascript +class ErrorBoundary extends React.Component { + constructor(props) { + super(props); + this.state = { hasError: false }; + } + + componentDidCatch(error, info) { + // Display fallback UI + this.setState({ hasError: true }); + // You can also log the error to an error reporting service + logErrorToMyService(error, info); + } + + render() { + if (this.state.hasError) { + // You can render any custom fallback UI + return

Something went wrong.

; + } + return this.props.children; + } +} +``` + +而后可作为一个正常组件进行使用: + +```javascript + + + +``` + +`componentDidCatch()`方法的作用类似于JavaScript的`catch {}`,但仅针对组件。仅有类组件可以成为错误边界。实际上,大多数时间你会想仅声明一次错误边界组件并在整个应用中使用。 + +注意,**错误边界仅可以捕获树中后代的组件错误**。一个错误边界无法捕获其自身的错误。若错误边界尝试渲染错误信息失败,则该错误会传递至上方最接近的错误边界。而这也类似JavaScript中的`catch {}`块的工作方式。 + +## Live Demo + +查看[在React 16测试版](https://github.com/facebook/react/issues/10294)中[关于如何声明和使用错误边界的例子](https://codepen.io/gaearon/pen/wqvxGa?editors=0010)。 + +## 放置错误边界 + +错误边界的粒度完全取决于你。你可能将其包装在顶层路由组件中并为用户展示"内部异常(Something went wrong)"的信息,类似于服务端框架处理崩溃。你可能也会在错误边界包装一些内部组件用以保护不会让应用的余下部分不会崩溃。 + +## 未捕获错误的新行为 + +这一改变有一个重要的意义。**作为React 16中不是由错误边界引起的错误将会使得整个React组件树被卸载。** + +我们曾争论这一决定,但在我们的经验中,将损坏的UI留在那里要比完全移除它要糟糕得多。例如,在类似Messenger这样的产品中留下可见的损坏的UI可能会导致一些人将信息发送给错误的人。类似地,对于支付应用来说显示错误的金额要比什么都不显示糟糕得多。 + + +这一改变意味着随着迁移至React 16,你们将会发现之前未留意过的应用程序存在的崩溃。增加错误边界能够让你在发生异常时提供更好的用户体验。 + +例如,Facebook Messenger将边栏,信息面板,会话日志以及消息输入的内容包装到单独的错误边界中。若其中某一个组件的UI崩溃了,其余的仍能正常交互。 + +我们也鼓励你使用JS错误报告服务(或自己构建)以让你能够了解在产品中产生的未处理的异常,并修复它们。 + +## 组件栈追踪 + +React 16会打印所有在开发环节中发生在渲染过程的错误到控制台,即使应用程序意外地将他们吞了。除了错误信息和JavaScript堆栈,其还提供了组件栈追踪。闲杂你可以在组件树中精确地查看错误产生的地方: + +Component stack traces in error message + +你也可以在组件堆栈中查看文件名和行数。这一功能在[Create React App 项目](https://github.com/facebookincubator/create-react-app)中默认开启: + +Component stack traces with line numbers in error message + +若你不使用Create React App,你可以手动添加[该插件](https://www.npmjs.com/package/babel-plugin-transform-react-jsx-source) 到你的Babel配置中。注意其仅能在开发环境中使用并**禁止在生产环境中使用。** + +## 为何不使用`try` / `catch`? + +`try` / `catch` 很好但其仅适用于命令式的代码: + +```javascript +try { + showButton(); +} catch (error) { + // ... +} +``` + +然而,React组件是声明式的,并指定了什么应该被渲染: + +```javascript +