-
Notifications
You must be signed in to change notification settings - Fork 27
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
refactor: clean up unnecessary props and types, refactor <Route>
to always render as children
#2995
Conversation
🦋 Changeset detectedLatest commit: 461f7ac The changes in this PR will be included in the next version bump. This PR includes changesets to release 35 packages
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 |
type Props<AdditionalEnvironmentProperties extends {}> = { | ||
environment: TProviderProps<AdditionalEnvironmentProperties>['environment']; | ||
type TApplicationEntryPointProps = { | ||
environment: TProviderProps<{}>['environment']; |
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.
This type of change is done in many places in this PR.
- Renamed the type
- Removed the type argument
AdditionalEnvironmentProperties
const browserLocale = getBrowserLocale(window); | ||
return ( | ||
<> | ||
<Suspense fallback={<ApplicationLoader />}> |
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.
Just moved up...
<ReduxProvider store={internalReduxStore}> | ||
<ApolloProvider client={apolloClient}> | ||
<Suspense fallback={<ApplicationLoader />}> |
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.
...from here.
Needed for a follow up PR.
<Route | ||
exact={true} | ||
path="/" | ||
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.
No more render
or component
prop, routes are rendered as children of <Route>
@@ -191,13 +191,9 @@ export interface ApplicationWindow extends Window { | |||
frontendHost: string; | |||
servedByProxy: boolean; | |||
// Optional properties. To use them, pass them to the `additionalEnv` object of the application config. | |||
mcProxyApiUrl?: string; |
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 only used internally and should not be defined as a "default" field
enableSignUp?: boolean; | ||
enableLongLivedFeatureFlags?: boolean; | ||
useFullRedirectsForLinks?: boolean; |
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.
Same for these
type TAdditionalEnvironmentProperties = { | ||
mcProxyApiUrl?: string; | ||
}; |
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 can then simply define a type to extend the app context and include the fields that we expect here to be optionally provided (via the additionalEnv
config field)
type TAdditionalEnvironmentProperties = { | ||
enableLongLivedFeatureFlags?: boolean; | ||
}; |
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.
Here's another one
const applicationContext = useApplicationContext<{ | ||
useFullRedirectsForLinks?: boolean; | ||
}>(); |
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.
Here as well
Deploy preview for merchant-center-application-kit ready! ✅ Preview Built with commit 461f7ac. |
@@ -25,14 +30,11 @@ import ApplicationEntryPoint from '../application-entry-point'; | |||
import messages from './messages'; | |||
|
|||
type QueryParams = { | |||
projectKey: string; | |||
projectKey?: string; |
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 query param is actually optional.
type Props = { | ||
projectKey: string; | ||
type TFetchProjectProps = { | ||
projectKey?: string; |
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 optional!
@@ -1,4 +1,4 @@ | |||
query FetchProject($projectKey: String!) { | |||
query FetchProject($projectKey: String) { |
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.
Yep, it's optional 😊
9175c4b
to
aed5e9f
Compare
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.
Thanks, it all looks good to me!
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.
👍
aed5e9f
to
9325e29
Compare
…lways render as children
9325e29
to
461f7ac
Compare
Extracted from #2821
AdditionalEnvironmentProperties
is not really used and needed by the internal components. Let's remove it.<Route>
components to render as children (as recommended when upgrading to v6).