-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SIGNIFICANT] Remove redundant render in react #2503
Changes from 1 commit
ebf57a5
eb04cb7
45de9cd
c6c1366
6486dd9
9467976
4242993
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React, { Component } from 'react'; | ||
|
||
function log(name) { | ||
console.log(`LifecycleLogger: ${name}`); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feels like a linter warning ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think I should use addon-actions for this instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can just ignore the warning =) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
} | ||
|
||
// A component that logs its lifecycle so we can check that things happen | ||
// the right number of times (i.e. we are using React properly) | ||
export default class LifecycleLogger extends Component { | ||
constructor() { | ||
super(); | ||
log('contructor'); | ||
} | ||
componentWillMount() { | ||
log('componentWillMount'); | ||
} | ||
componentDidMount() { | ||
log('componentDidMount'); | ||
} | ||
componentWillReceiveProps() { | ||
log('componentWillReceiveProps'); | ||
} | ||
componentWillUpdate() { | ||
log('componentWillUpdate'); | ||
} | ||
componentDidUpdate() { | ||
log('componentDidUpdate'); | ||
} | ||
componentWillUnmount() { | ||
log('componentWillUnmount'); | ||
} | ||
componentDidCatch() { | ||
log('componentDidCatch'); | ||
} | ||
render() { | ||
log('render'); | ||
return <div>Lifecycle methods are logged to the console</div>; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&&?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😊