-
Notifications
You must be signed in to change notification settings - Fork 37
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
✨ Add dynamic page title to all pages #20
Conversation
Your Render PR Server URL is https://ozone-sandbox-pr-20.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-cmrsen6v3ddc73d5ib1g. |
Your Render PR Server URL is https://ozone-staging-pr-20.onrender.com. Follow its progress at https://dashboard.render.com/web/srv-cmrsen6v3ddc73d5ib4g. |
app/events/[id]/page.tsx
Outdated
useEffect(() => { | ||
if (event) { | ||
const eventTitle = | ||
MOD_EVENT_TITLES[event.event.$type as string] || 'Moderation' | ||
document.title = `${eventTitle} Event #${id}` | ||
} else { | ||
document.title = `Moderation Event #${id}` | ||
} | ||
}, [id, event]) |
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.
Since the title is just a string which itself can be used as an effect dependency, you could imagine a hook for this like:
function useTitle(title: string) {
useEffect(() => {
document.title = title
}, [title])
}
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.
hmm... I mean we could also use the hook from react-use
package since we're using it already across the codebase.
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.
poked around, looks good!
Addresses #19
ozone-ui-page-title.mov