react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

Can't integrate with React-intl

Open withpublic opened this issue 2 years ago • 1 comments

I am trying to localize react-pdf using react-intl, but I get Unhandled Runtime Error Error: [React Intl] Could not find required intl object. <IntlProvider> needs to exist in the component ancestry.

I created a Viewer component and wrapped with injectIntl from react-intl package. It is a standard way of internationalization of the components. As soon as I wrapped it with injectIntl I got above error.

The component is as follows, simplified

import {Document, Page, View} from "@react-pdf/renderer";
import React, {Component} from "react";
import {injectIntl} from "react-intl";

class Viewer extends Component {
	render() {
		let {intl}=this.props;
		
		return (
			<Document>
				<Page style={styles.body} wrap>
					<View
						style={{
							height: 100, textAlign: "center", width: "50%",
							marginHorizontal: "auto"
						}}>
						{/*//Some components*/}
					</View>
				</Page>
			</Document>
		);
	}
}

export default injectIntl(Viewer);

withpublic avatar Jul 02 '23 11:07 withpublic

Cross-posted here https://www.brainpick.co.uk/questions/cant-integrate-with-react-intl-261, with a reward.

withpublic avatar Jul 05 '23 16:07 withpublic

Hi @diegomura @withpublic . I am just wondering if you have any idea what is causing this bug or if there are any work-arounds we could use until it's fixable?

PS. thanks @diegomura for your work on react-pdf – it's a very useful tool.

ShaunaMack avatar Apr 07 '24 08:04 ShaunaMack