Created
October 3, 2021 15:44
-
-
Save albertBarsegyan/36a6621c720ce4fe85eacf189020ed86 to your computer and use it in GitHub Desktop.
locale links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import Link from 'next/link'; | |
| import { useRouter } from 'next/dist/client/router'; | |
| export default function Test() { | |
| const { locales, asPath } = useRouter(); | |
| return ( | |
| <div> | |
| {locales.map((localeName) => { | |
| return ( | |
| <div key={localeName}> | |
| <Link href={asPath} passHref locale={localeName}> | |
| <a>{localeName}</a> | |
| </Link> | |
| </div> | |
| ); | |
| })} | |
| </div> | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment