Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of null (reading 'useMemo') #49

Closed
Heilemann opened this issue Dec 10, 2023 · 2 comments
Closed

Cannot read properties of null (reading 'useMemo') #49

Heilemann opened this issue Dec 10, 2023 · 2 comments

Comments

@Heilemann
Copy link

Heilemann commented Dec 10, 2023

I'm getting this error in my CRA project:

ERROR
Cannot read properties of null (reading 'useMemo')
TypeError: Cannot read properties of null (reading 'useMemo')
    at Object.useMemo (http://localhost:3000/static/js/bundle.js:241387:25)
    at defaultLayoutPlugin (http://localhost:3000/main.f2519163e0f365851fb8.hot-update.js:1013:32)
    at PdfViewer (http://localhost:3000/main.991012cbdc34eb302c69.hot-update.js:29:124)
    at renderWithHooks (http://localhost:3000/static/js/bundle.js:144726:22)
    at mountIndeterminateComponent (http://localhost:3000/static/js/bundle.js:148012:17)
    at beginWork (http://localhost:3000/static/js/bundle.js:149308:20)
    at HTMLUnknownElement.callCallback (http://localhost:3000/static/js/bundle.js:134318:18)
    at Object.invokeGuardedCallbackDev (http://localhost:3000/static/js/bundle.js:134362:20)
    at invokeGuardedCallback (http://localhost:3000/static/js/bundle.js:134419:35)
    at beginWork$1 (http://localhost:3000/static/js/bundle.js:154293:11)

Here's the component:

import { Viewer, Worker } from '@react-pdf-viewer/core'
import { defaultLayoutPlugin } from '@react-pdf-viewer/default-layout'

import '@react-pdf-viewer/core/lib/styles/index.css'
import '@react-pdf-viewer/default-layout/lib/styles/index.css'

const PdfViewer = () => {
	const defaultLayoutPluginInstance = defaultLayoutPlugin()

	return (
		<Worker workerUrl='https://unpkg.com/pdfjs-dist@2.15.349/build/pdf.worker.js'>
			<div
				style={{
					height: '750px',
					width: '900px',
					marginLeft: 'auto',
					marginRight: 'auto',
				}}
			>
				<Viewer
					fileUrl={`/assets/pdf/traveller.pdf`}
					plugins={[defaultLayoutPluginInstance]}
				/>
			</div>
		</Worker>
	)
}

export default PdfViewer

If I remove the plugin, that error goes away, but then I get one about useState instead.

@Heilemann
Copy link
Author

Same issues as #47

@Heilemann
Copy link
Author

Self goal. I had installed the libraries in the wrong folder (one up from my client, in my server).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant