-
Notifications
You must be signed in to change notification settings - Fork 2k
Pass siteSlug as component prop instead of using router instances #103502
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
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~29 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
import PageLayout from '../../components/page-layout'; | ||
import SettingsPageHeader from '../settings-page-header'; | ||
import { LaunchForm } from './launch-form'; | ||
import { PrivacyForm } from './privacy-form'; | ||
|
||
export default function SiteVisibilitySettings() { | ||
const { siteSlug } = siteSettingsSiteVisibilityRoute.useParams(); | ||
const { siteSlug } = useParams( { strict: false } ); |
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.
strict: false
is needed otherwise useParams
throws an error saying that the param from
is needed. Adding the from
defeats the purpose of this PR since it's the route path.
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 makes sense to me. Thanks
So just for clarify, we lose the "types" here right? Doesn't seem like a big problem right now but we might want to restore "from" later if reusability of these components is not needed anymore. The other possibility is to actually reuse UI components, the "route" component become just wrappers. |
@youknowriad I ended up passing siteSlug as a props component from the router instead of using router instances. Let me know if there are concerns with this approach, thanks. |
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
It works for me :) |
24df7d2
to
f67a920
Compare
Proposed Changes
This PR passes siteSlug as component prop from the router, instead of explicitly using path-specific route instances within components. This change allows the components to decouple from route instances, making them reusable in the case of backporting where another router instance is used.
Why are these changes being made?
Decouple components from route instances.
Testing Instructions
Pre-merge Checklist