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

Site 3913 #119

Merged
merged 2 commits into from
Sep 5, 2024
Merged

Site 3913 #119

merged 2 commits into from
Sep 5, 2024

Conversation

ebrockainq
Copy link
Contributor

No description provided.

const sendDirectTabs: TabInputs[] = [
{ tabName: 'VERSION V1.3', tabIndex: 0, tabPanel: <Version13 /> },
{ tabName: 'VERSION V1.2', tabIndex: 1, tabPanel: <Version12 /> },
{ tabName: 'Message Status', tabIndex: 2, tabPanel: <MessageStatus /> },
]

useEffect(() => {
Copy link
Contributor

@drbgfc drbgfc Sep 5, 2024

Choose a reason for hiding this comment

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

Although I'm sure this code works, you might want to consider useRouter for the sake of simpler code/easier maintenance.

As an (untested example):

import { useRouter } from 'next/router'

...

  const router = useRouter()

...

  useEffect(() => {
    const handleRouteChange = () => {
      const hash = router.asPath.split('#')[1]
      const formattedHash = hash ? hash.replace(/-/g, ' ').toLowerCase() : ''
      const tab = sendDirectTabs.find((t) => t.tabName.toLowerCase() === formattedHash)
      setSelectedTab(tab ? tab.tabName : 'VERSION V1.3')
    }

    handleRouteChange() // Set initial tab
    router.events.on('hashChangeComplete', handleRouteChange)

    return () => {
      router.events.off('hashChangeComplete', handleRouteChange)
    }
  }, [router])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted, having issue with the implementation of this for now, so will try to add it in later

@ebrockainq ebrockainq merged commit c3fc404 into dev Sep 5, 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.

2 participants