Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Upgrade guide implementing RelativeTime behavior (#1374)
Adding a section on how to implement the old `FormattedRelative` behavior in v3. As per discussion in: #1364 Another option I was thinking about was adding an example was: ```js import React from 'react'; import PropTypes from 'prop-types'; import { selectUnit } from '@formatjs/intl-utils'; import { FormattedRelativeTime } from 'react-intl'; export const FormattedRelative = ({ value, ...props }) => { const selectedUnit = selectUnit(new Date(value) || Date.now()); return <FormattedRelativeTime {...props} value={selectedUnit.value} unit={selectedUnit.unit} />; }; FormattedRelative.propTypes = { value: PropTypes.oneOfType([ PropTypes.date, PropTypes.string ]).isRequired }; export default FormattedRelative; ``` Thoughts?
- Loading branch information