Last active
October 17, 2019 16:53
-
-
Save matheusrod92/7fb222b4f54927218761350af0c83046 to your computer and use it in GitHub Desktop.
Messages with links using react-intl
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 { FormattedMessage } from 'react-intl' | |
import messages from './messages' | |
// it can be a component or a variable | |
const Link = () => ( | |
<a nohref rel="noopener noreferrer"> | |
<FormattedMessage {...messages.reminderLink} /> | |
</a> | |
) | |
const Component = () => { | |
// it can be a component or a variable | |
const link = <a nohref><FormattedMessage {...messages.reminderLink} /></a> | |
return ( | |
<div> | |
<FormattedMessage {...messages.reminderHouseAccessItems} values={{ link }} /> | |
{/* OR */} | |
<FormattedMessage {...messages.reminderHouseAccessItems} values={{ link: <Link /> }} /> | |
</div> | |
) | |
} | |
export default Component |
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 { defineMessages } from 'react-intl' | |
export default defineMessages({ | |
reminderHouseAccessItems: { | |
id: 'app.containers.ConfirmInspection.reminderHouseAccessItems', | |
defaultMessage: 'Lembre-se de deixar as chaves e a {link} para o vistoriador', | |
}, | |
reminderLink: { | |
id: 'app.containers.ConfirmInspection.reminderLink', | |
defaultMessage: 'autorização de entrada', | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment