Skip to content
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

Image upload example is too complicated #2152

Open
alexslavr opened this issue Nov 25, 2021 · 0 comments
Open

Image upload example is too complicated #2152

alexslavr opened this issue Nov 25, 2021 · 0 comments
Labels
enhancement Issues related to potential improvements and new features

Comments

@alexslavr
Copy link

The image upload example is too complicated.

All state in the single hook is not readable:
https://github.com/reimagined/resolve/blob/dev/examples/ts/personal-data/client/components/ImageUpload.tsx#L27
React docs about splitting state variables:
https://reactjs.org/docs/hooks-faq.html#should-i-use-one-or-many-state-variables

What is the difference between token and staticToken ?
https://github.com/reimagined/resolve/blob/dev/examples/ts/personal-data/client/components/ImageUpload.tsx#L58
https://github.com/reimagined/resolve/blob/dev/examples/ts/personal-data/client/components/ImageUpload.tsx#L96

The cdnUrl available also in ResolveContext, uploader context is redundant:
https://github.com/reimagined/resolve/blob/dev/examples/ts/personal-data/client/components/ImageUpload.tsx#L55
Related issue:
#2150

It will be better to split ImageUploader react component into something like:

Parent component:

// hooks and upload logic
<ImageUploader /> - 

Upload renderer:
https://github.com/reimagined/resolve/blob/dev/examples/ts/personal-data/client/components/ImageUpload.tsx#L115

<UploadForm  fields={form.fields} onSubmitHandler={onSubmitHandler}  />

Maybe other forms:

...
 <OtherForms defaultValue={cdnUrl} onClick={handleGetUrl}  /> 
...
@MrCheater MrCheater added the enhancement Issues related to potential improvements and new features label Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issues related to potential improvements and new features
Projects
None yet
Development

No branches or pull requests

2 participants