Created
February 11, 2020 20:22
-
-
Save emersonlaurentino/67307e4306a7a3f2e602a360de5380fe to your computer and use it in GitHub Desktop.
React Intl with Hook
This file contains 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 { useIntl } from 'react-intl' | |
const AdminForm = () => { | |
const intl = useIntl() | |
return ( | |
<form> | |
<label> | |
<small>{intl.formatMessage({ id: 'admin/username.form.label' })}</small> | |
<input /> | |
</label> | |
<button type="submit"> | |
{intl.formatMessage({ id: 'admin/username.form.submit' })} | |
</button> | |
</form> | |
) | |
} | |
export default AdminForm |
Also, there are many other components that can be used:
https://github.com/formatjs/react-intl/blob/master/docs/Components.md
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would recommend using this method when possible instead: