-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[v4][FileUpload] Remove withContext/withRef #1491
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
Conversation
a2616cc
to
83981b9
Compare
import DropZoneContext from '../../context'; | ||
import {usePolaris} from '../../../../hooks'; | ||
|
||
export interface State { |
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.
We have no need for state. See below 👀
const {size, type} = React.useContext(DropZoneContext); | ||
const suffix = capitalize(type); | ||
const { | ||
actionTitle = translate(`Polaris.DropZone.FileUpload.actionTitle${suffix}`), |
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.
We use the provided actionTitle/Hint and default it to what was previously the default on state
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 wonder why we had done that?
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.
Seems like it was to avoid string translation however object lookup is inexpensive so I'm not sure why, or this approach didn't occur when developing the component? 🤷♂
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.
The code looks fine. Just questioning why we were using state
to hold those props?
WHY are these changes introduced?
Part of #1484
WHAT is this pull request doing?
I'm converting FileUpload to a functional component and removing
withRef
/withContext
How to 🎩
Tests / percy / development server