-
Notifications
You must be signed in to change notification settings - Fork 106
refactor: convert to functional component #124
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
base: master
Are you sure you want to change the base?
Conversation
noghartt
left a comment
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.
let some review comments here
| if (results.access_token) { | ||
| // Keeping this to keep it backwards compatible, but also returning raw results to account for future changes. | ||
| this.props.onLoginSuccess(results.access_token, results); | ||
| onLoginSuccess(results.access_token, results); |
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.
should we assume that onLoginSuccess is required every time?
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.
add a conditional to validate that onLoginSuccess exists
| onLoginSuccess(results.access_token, results); | |
| if (onLoginSuccess) { | |
| onLoginSuccess(results.access_token, results); | |
| } |
| if (responseType === 'code' && !appSecret) { | ||
| if (code) { | ||
| this.props.onLoginSuccess(code, results); | ||
| onLoginSuccess(code, results); |
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.
same here
| onLoginSuccess(code, results); | ||
| } else { | ||
| this.props.onLoginFailure(results); | ||
| onLoginFailure(results); |
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.
same here
|
|
||
| if (res) { | ||
| this.props.onLoginSuccess(res.data, results); | ||
| onLoginSuccess(res.data, results); |
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.
same here
| onLoginSuccess(res.data, results); | ||
| } else { | ||
| this.props.onLoginFailure(results); | ||
| onLoginFailure(results); |
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.
same here
| this.hide(); | ||
| this.props.onLoginFailure(json); | ||
| hide(); | ||
| onLoginFailure(json); |
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.
same here
| webViewState.url === 'https://www.instagram.com/' | ||
| ) { | ||
| this.setState({ key: key + 1 }); | ||
| setKey((k) => k + 1); |
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.
why exactly do you need to increase the key counter on that? just to force a rerender?
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.
I didn't understand too
Should we do this change in this PR, since its only goal is to move from class to FC?
Most react code written today uses functional components and hooks, with this PR, the main class component (
Instagram) is converted to its equivalent functional component.It does not lead to changes in behavior or improvements in performance, but it brings the code closer to the present day and will facilitate future maintenance by other people.
renderCloseandrenderWebvieware still inner functions of the main component