Skip to content

Commit

Permalink
fix: onError 对应的生命周期应是 componentDidCatchError (#2571)
Browse files Browse the repository at this point in the history
  • Loading branch information
js-newbee authored and luckyadam committed Mar 25, 2019
1 parent ed7e73f commit abbe73f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/taroize.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Taro 会将原始文件的生命周期钩子函数转换为 Taro 的生命周期
| onHide | componentDidHide |
| onReady | componentDidMount |
| onUnload | componentWillUnmount |
| onError | componentCatchError |
| onError | componentDidCatchError |
| App.onLaunch | componentWillMount |
| Component.created | componentWillMount |
| attached | componentDidMount |
Expand Down
8 changes: 4 additions & 4 deletions packages/taro-cli/__tests__/__snapshots__/rn.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let App = (_temp = _class = class App extends Component {
componentDidMount() {}
componentDidShow() {}
componentDidHide() {}
componentCatchError() {}
componentDidCatchError() {}
render() {
return <RootStack />;
}
Expand Down Expand Up @@ -79,7 +79,7 @@ let App = (_temp = _class = class App extends Component {
componentDidHide() {}
componentCatchError() {}
componentDidCatchError() {}
render() {
return <RootStack />;
Expand Down Expand Up @@ -161,7 +161,7 @@ let App = (_temp = _class = class App extends Component {
componentDidHide() {}
componentCatchError() {}
componentDidCatchError() {}
render() {
return <Provider store={store}>
Expand Down Expand Up @@ -217,7 +217,7 @@ let App = (_temp = _class = class App extends Component {
componentDidHide() {}
componentCatchError() {}
componentDidCatchError() {}
render() {
return <RootStack />;
Expand Down
6 changes: 3 additions & 3 deletions packages/taro-cli/__tests__/mocks/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class App extends Component {
componentDidHide () {}
componentCatchError () {}
componentDidCatchError () {}
render () {
return (
Expand Down Expand Up @@ -88,7 +88,7 @@ class App extends Component {
componentDidHide () {}
componentCatchError () {}
componentDidCatchError () {}
render () {
return (
Expand Down Expand Up @@ -133,7 +133,7 @@ class App extends Component {
componentDidHide () {}
componentCatchError () {}
componentDidCatchError () {}
render () {
return (
Expand Down
2 changes: 0 additions & 2 deletions packages/taro-cli/templates/redux/appjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class App extends Component {

componentDidHide () {}

componentCatchError () {}

componentDidCatchError () {}

// 在 App 类中的 render() 函数没有实际作用
Expand Down
4 changes: 2 additions & 2 deletions packages/taroize/src/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const enum Lifecycle {
componentDidMoved = 'componentDidMoved',
shouldComponentUpdate = 'shouldComponentUpdate',
componentWillReceiveProps = 'componentWillReceiveProps',
componentCatchError = 'componentCatchError'
componentDidCatchError = 'componentDidCatchError'
}

export const PageLifecycle = new Map<string, string>()
Expand All @@ -22,5 +22,5 @@ PageLifecycle.set('onShow', Lifecycle.componentDidShow)
PageLifecycle.set('onReady', Lifecycle.componentDidMount)
PageLifecycle.set('onHide', Lifecycle.componentDidHide)
PageLifecycle.set('onUnload', Lifecycle.componentWillUnmount)
PageLifecycle.set('onError', Lifecycle.componentCatchError)
PageLifecycle.set('onError', Lifecycle.componentDidCatchError)
PageLifecycle.set('onLaunch', Lifecycle.componentWillMount)

0 comments on commit abbe73f

Please sign in to comment.