Skip to content

Instantly share code, notes, and snippets.

@matheusrod92
Last active October 17, 2019 16:53
Show Gist options
  • Save matheusrod92/7fb222b4f54927218761350af0c83046 to your computer and use it in GitHub Desktop.
Save matheusrod92/7fb222b4f54927218761350af0c83046 to your computer and use it in GitHub Desktop.
Messages with links using react-intl
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
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