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

Update GameDetails title to show the game score - closes #111 #112

Merged
merged 2 commits into from
Mar 22, 2022

Conversation

willianjusten
Copy link
Owner

Description

This PR adds the option to show the game score right into the browser tab with its title. I also added the same typing that @vedovelli did on #109 and since we need this title to be updated even without being the active tab, I removed the logic to check the tab (note: this only occurs on this page, the index page will keep the refetch only when active)

After

WhatsApp Image 2022-03-20 at 10 48 23 PM

@willianjusten willianjusten self-assigned this Mar 21, 2022
@vercel
Copy link

vercel bot commented Mar 21, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/willianjusten/nba-remix/CafZXWgj9M6ekdXT3hfvQPcJdtsj
✅ Preview: https://nba-remix-git-update-title-scores-willianjusten.vercel.app

}

export default function Game() {
export default function GameDetails() {
const { game: loaderGame } = useLoaderData()
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want loaderGame to be typed in within the React Component, then you should do:

const { game: loaderGame } = useLoaderData<LoaderData>()

Copy link
Owner Author

Choose a reason for hiding this comment

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

Ops, missed this point indeed xD

Comment on lines 87 to 89
const setTitle = (game: Game) => {
document.title = `${game.vTeam.tn} ${game.vTeam.score} x ${game.hTeam.score} ${game.hTeam.tn} | NBA Remix`
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to get game data in meta tags to set the programmatic values?

Copy link
Owner Author

Choose a reason for hiding this comment

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

We already use the meta tags values to the other data, I did this way because we want to refresh the values as soon as we get new data from the fetch without refreshing the page.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'll try something different after, I created this more to see if it works but definitely can be improved.

@helderberto helderberto self-requested a review March 22, 2022 10:07
@willianjusten willianjusten merged commit e38bbdb into main Mar 22, 2022
@willianjusten willianjusten deleted the update-title-scores branch March 22, 2022 23:38
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.

4 participants