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

Create a new React hook to access Projects Images rewrite configuration #2639

Merged
merged 9 commits into from
Jun 15, 2022

Conversation

ddouglasz
Copy link
Contributor

Create react hook to access Project's images URLs rewrite rules configurations information from context.
See more on ticket here: #2571

@changeset-bot
Copy link

changeset-bot bot commented Jun 9, 2022

🦋 Changeset detected

Latest commit: 5be06d1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@commercetools-frontend/application-shell-connectors Patch
@commercetools-frontend/application-components Patch
@commercetools-frontend/application-shell Patch
@commercetools-frontend/permissions Patch
merchant-center-application-template-starter Patch
playground Patch
@commercetools-local/visual-testing-app Patch
@commercetools-website/components-playground Patch
@commercetools-frontend/cypress Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot temporarily deployed to Preview June 9, 2022 12:35 Destroyed
@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2022

Deploy preview for merchant-center-application-kit ready!

✅ Preview
https://merchant-center-application-dror8ui3h-commercetools.vercel.app
https://appkit-sha-ed9023234ccc4f7fe14d6b5cad33a4d8dba764fd.commercetools.vercel.app
https://appkit-pr-2639.commercetools.vercel.app

Built with commit 5be06d1.
This pull request is being automatically deployed with vercel-action

@ddouglasz ddouglasz added 🚧 Status: WIP Work in progress and removed 🚧 Status: WIP Work in progress labels Jun 9, 2022
Copy link
Contributor

@kark kark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm adding some comments to better understand the context of the PR 🙂

@github-actions github-actions bot temporarily deployed to Preview June 9, 2022 22:06 Destroyed
/>
);
const WrappedComponent = (props: Props) => {
const imageregexContext = useProjectExtensionImageRegex();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can also use a deprecation message with the HOC.
Perhaps something like this:

@commercetools-frontend/application-shell-connectors: It is not recommended to use the 'withProjectExtensionImageRegex' high order component anymore. Please use the 'useProjectExtensionImageRegex' hook instead.

Not 100% sure though since maybe we have customers who still use React class components and they wouldn't be able to use the hook.

Let's see what the rest of the team think about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point. I am not sure too but it would be nice to see what the team thinks too but I will also update it.

Copy link
Contributor

@kark kark Jun 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Carlos mentioned, in some contexts HOC/render prop version is the only choice. On the other hand, for instance Apollo deprecated all their HOCs and render prop components in favour of the hooks in the v3 of their client. For what it's worth, I'm not sure either, but I guess that is OK.

@ddouglasz
Copy link
Contributor Author

Thank you,
Please find all feedback updates here 🙂:
d9d6cfe

@github-actions github-actions bot temporarily deployed to Preview June 10, 2022 09:04 Destroyed
@CarlosCortizasCT
Copy link
Contributor

CarlosCortizasCT commented Jun 10, 2022

I guess the build is failing because now we're using the tiny-warning package but we forgot to add the dependency to this module package.json.

@ddouglasz
Copy link
Contributor Author

True! Thank you.
I have updated here: 54ea1b6

Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to review the version we used for the tiny-warning message.
Also, I left a couple of comments regarding changeset and docs.

@github-actions github-actions bot temporarily deployed to Preview June 10, 2022 11:06 Destroyed
@ddouglasz
Copy link
Contributor Author

ddouglasz commented Jun 10, 2022

I can raise a new PR for the docs update.
changeset summary and tiny-warning dependency updated here:
9438549

@github-actions github-actions bot temporarily deployed to Preview June 10, 2022 11:35 Destroyed
@github-actions github-actions bot temporarily deployed to Preview June 10, 2022 11:56 Destroyed
Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go from my side 👏

@github-actions github-actions bot temporarily deployed to Preview June 10, 2022 12:01 Destroyed
Copy link
Contributor

@kark kark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 👍 I'm leaving only some final (minor) comments.

/>
);
const WrappedComponent = (props: Props) => {
const imageregexContext = useProjectExtensionImageRegex();
Copy link
Contributor

@kark kark Jun 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Carlos mentioned, in some contexts HOC/render prop version is the only choice. On the other hand, for instance Apollo deprecated all their HOCs and render prop components in favour of the hooks in the v3 of their client. For what it's worth, I'm not sure either, but I guess that is OK.

@ddouglasz ddouglasz force-pushed the de-projects-images-rewrite-config-hook branch from 9f3c275 to 5be06d1 Compare June 13, 2022 10:23
@github-actions github-actions bot temporarily deployed to Preview June 13, 2022 10:37 Destroyed
@ddouglasz ddouglasz merged commit 78de0ec into main Jun 15, 2022
@ddouglasz ddouglasz deleted the de-projects-images-rewrite-config-hook branch June 15, 2022 09:53
@ghost ghost mentioned this pull request Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants