-
Notifications
You must be signed in to change notification settings - Fork 1
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
Auto-Increment and Error Messaging for Duplicate Contingency List Names in Script #277
Conversation
…ters contingency list Name when Copied to Script Signed-off-by: achour94 <berrahmaachour@gmail.com>
…ters contingency list Name when Copied to Script Signed-off-by: achour94 <berrahmaachour@gmail.com>
…increment_alias_copy_name
if (initialValue !== '') { | ||
updateFormState(initialValue); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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.
forbidden in our code base :)
…increment_alias_copy_name
…increment_alias_copy_name
Signed-off-by: achour94 <berrahmaachour@gmail.com>
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.
Code Ok
Test Ok
useEffect(() => { | ||
if (initialValue !== '') { | ||
updateFormState(initialValue); | ||
setValue(initialValue); |
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.
Does this effect run multiple times ? If not, there's not need for setValue as initialValue is passed to the useState() ?
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.
It's a bad name "initialValue" if it triggers additional behaviors when it changes. In react the convention is to only use the value for the first render
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.
yes, it willl trigger the useeffect twice in the case we will get the name from the backend
<CircularProgress /> | ||
) : ( | ||
<NameWrapper | ||
initialValue={generatedName} |
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 would fix the initialValue behavior and restore the value={...} and onChange{...} prop
open, | ||
onClose, | ||
onClick, | ||
currentName, | ||
title, | ||
}) => { | ||
const [newNameValue, setNewNameValue] = React.useState(currentName); | ||
const [generatedName, setGeneratedName] = useState(''); | ||
const [newNameValue, setNewNameValue] = useState(currentName); |
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 we do use generatedName and newNameValue
Maybe one is enough
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.
because in that case (initialValue={newNameValue}) the useEffect with initialValue as a dependency will be triggered each time newNameValue is changed
replaced with #285 |
Implement Automatic Incrementation and Error Message for existing filters contingency list Name when Copied to Script