Skip to content

Commit

Permalink
feat(react-i18n): allow react element in HtmlTrans element prop
Browse files Browse the repository at this point in the history
  • Loading branch information
flepretre committed Dec 18, 2018
1 parent 654b030 commit 1737abb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,13 @@ exports[`i18n.renderProps should return html translation in a div 1`] = `
}
/>
`;

exports[`i18n.renderProps should return html translation in a react element 1`] = `
<Dummy
dangerouslySetInnerHTML={
Object {
"__html": "<div>foo.bar</div>",
}
}
/>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ describe('i18n.renderProps', () => {

expect(wrapper.shallow()).toMatchSnapshot();
});

it('should return html translation in a react element', () => {
const Dummy = props => <dummy {...props} />;
const wrapper = getWrapper({ element: Dummy });

expect(wrapper.shallow()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ HtmlTrans.defaultProps = {
};

HtmlTrans.propTypes = {
element: PropTypes.string,
element: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
i18nKey: PropTypes.string.isRequired,
data: PropTypes.object,
number: PropTypes.number,
Expand Down

0 comments on commit 1737abb

Please sign in to comment.