refactor: convert to functional component#124
Open
ddanielsantos wants to merge 1 commit intohungdev:masterfrom
Open
refactor: convert to functional component#124ddanielsantos wants to merge 1 commit intohungdev:masterfrom
ddanielsantos wants to merge 1 commit intohungdev:masterfrom
Conversation
noghartt
reviewed
Aug 18, 2024
| 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.
should we assume that onLoginSuccess is required every time?
There was a problem hiding this comment.
add a conditional to validate that onLoginSuccess exists
Suggested change
| 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); |
| onLoginSuccess(code, results); | ||
| } else { | ||
| this.props.onLoginFailure(results); | ||
| onLoginFailure(results); |
|
|
||
| if (res) { | ||
| this.props.onLoginSuccess(res.data, results); | ||
| onLoginSuccess(res.data, results); |
| onLoginSuccess(res.data, results); | ||
| } else { | ||
| this.props.onLoginFailure(results); | ||
| onLoginFailure(results); |
| this.hide(); | ||
| this.props.onLoginFailure(json); | ||
| hide(); | ||
| onLoginFailure(json); |
| webViewState.url === 'https://www.instagram.com/' | ||
| ) { | ||
| this.setState({ key: key + 1 }); | ||
| setKey((k) => k + 1); |
There was a problem hiding this comment.
why exactly do you need to increase the key counter on that? just to force a rerender?
Author
There was a problem hiding this comment.
I didn't understand too
Should we do this change in this PR, since its only goal is to move from class to FC?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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