-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix order of changing state #108
Conversation
Codecov Report
@@ Coverage Diff @@
## master #108 +/- ##
=======================================
Coverage 83.73% 83.73%
=======================================
Files 43 43
Lines 2281 2281
=======================================
Hits 1910 1910
Misses 371 371 Continue to review full report at Codecov.
|
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.
Removing unnecessary code (e.g. state.form
and return
of onSubmit()
) is a great work.
I made a comment, could you check it?
@@ -88,7 +88,7 @@ class AddModelFileFormImpl extends React.Component<AddModelFileFormProps, AddMod | |||
validationSchema={AddModelFileSchema} | |||
onSubmit={this.onSubmit} | |||
onReset={this.onCancel}> | |||
{({ errors, touched, setFieldValue, isSubmitting }) => ( | |||
{({ errors, touched, setFieldValue }) => ( |
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.
You don't need to rewrite here. You can write this like this way.
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.
LGTM
Current implementation of isSubmitting
, state.submitting
and state.submitted
is complicated. We need to fix them in the future...
What is this PR for?
fix error caused by second requests of API,
Currently display the previous result as notification because
prevState
of getDerivedStateFromProps is actually not previous state, so followings happen.(e.g. upload model)
setState({submitting: true})
in onSubmit, getDerivedStateFromProps is calleduploadModelStatus
is already success or fail, depending on the previous resultnextState.submitting
is true, so display the previous result as notfiication, not waiting for the current API request to return responseThis PR includes
state.form
because it is not used ( ca718a2 )prevState
to nextState` in getDerivedStateFromProps ( e0e1f75 )isSubmitting
because it does not change when API request failed ( 89e3ddc )What type of PR is it?
Bugfix
What is the issue?
N/A
How should this be tested?
write a method and a sample of command