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

✨ Add dynamic page title to all pages #20

Merged
merged 2 commits into from
Feb 7, 2024
Merged

✨ Add dynamic page title to all pages #20

merged 2 commits into from
Feb 7, 2024

Conversation

foysalit
Copy link
Contributor

Addresses #19

ozone-ui-page-title.mov

Copy link

render bot commented Jan 29, 2024

Copy link

render bot commented Jan 29, 2024

@foysalit foysalit requested review from bnewbold and devinivy January 29, 2024 15:42
Comment on lines 24 to 32
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])
Copy link
Collaborator

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])
}

Copy link
Contributor Author

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.

Copy link
Collaborator

@bnewbold bnewbold left a 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!

@foysalit foysalit merged commit f05587e into main Feb 7, 2024
3 checks passed
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