score:2
Accepted answer
Since your PDF file is located in the public
folder, you can reference the image's path directly in the filePath
prop.
You also need to make sure react-file-viewer
is only imported in the browser as it depends on window
being present to work properly. You can do so by dynamically importing the component through next/dynamic
with ssr: false
.
import dynamic from 'next/dynamic';
const FileViewer = dynamic(() => import('react-file-viewer'), {
ssr: false
});
export default function Index() {
return (
<FileViewer fileType="pdf" filePath="/pdf.pdf" />
);
};
Source: stackoverflow.com
Related Query
- How to import scss file as variable in react with typescript
- How to import Json file with React lazy loading?
- How to import .json file with typescript React App
- How to import react modules from an HTML file with no npm/webpack
- How to import PDF file with react-file-viewer in Next.js?
- How to import an html file with script in react .js file?
- How to import a CSS file in a React Component
- How to import CSS modules with Typescript, React and Webpack
- How to focus something on next render with React Hooks
- How to upgrade a React project built with create-react-app to the next create-react-app version?
- React - How to open PDF file as a href target blank
- How import object from external JS file in React JS using web pack
- How to import js modules (with absolute path) in my typescript file in React application?
- how to import HTML file into React component and use it as a component?
- How do I download a pdf file onClick with react-pdf?
- how to use .env file in a react js with typescript project?
- Serving static pdf with react webpack file loader
- how to import data in react from a js file to use in components
- How to properly import React JSX from separate file in Typescript 1.6
- How to enable absolute path aliases with eslint import plugin in a typescript react project?
- How do you correctly use React.lazy() in Typescript to import a react component with a generic type parameter?
- How to import a file into a react app that uses create react app as raw text?
- How to import an external file from project root with webpack?
- How to import a component or file in React using variables?
- How to import from React-Select CDN with React and Babel?
- How to import a sound file into react typescript component?
- How to import a css file in a react component as raw text?
- How to Import sass file to single components in React
- react js how to import only the required function from a file and not the all functions
- How to import file from public folder in react application?
More Query from same tag
- <UL> list item not being added in React
- Sending canvas.toDataURL() as FormData
- A specific piece of state does not update - React
- How to trigger this function on loading this React component, instead of requiring a button click?
- react-native-gesture-handler module error
- React/TypeScript: extending a component with additional properties
- What type should I declare for object rest props?
- Set Flexbox Min Height To Fill Remaining Screen in Scrolling Container
- Material-UI Drawer rounding off corners leaves whitespace
- React "export default" stateless component issue
- Duplicating an email form with an onClick
- Want to avoid multiple actions on click of a header
- Request had insufficient authentication scopes with google contacts
- React-slick custom arrow with styled-components
- Create nested form using react js
- Cross-Origin Request Blocked, header Access-Control-Allow-Origin missing
- How to create a common components in flux?
- Refactoring how react/node handles response
- useQuery doesn't fire on rerender
- How to include JavaScript libraries only in production build files of create-react-app?
- Is it possible to create an apk in Ionic 4 - (React) via CLI only?
- How to increase min-width in ".MuiSelect-select" in material ui Textfield with Select attribute also how to access Selectfield with Input adornment
- Node JS : JSON Refactoring based on the city
- setState does not change/rerender
- How to display an Error message when logging in fails in Reactjs
- Redux doesn't update component
- Handle login using Google Authentication in system with client and server running on different port reactJS and nodeJS
- TypeScript pass an array as argument
- Warning: validateDOMNesting(...): <tr> cannot appear as a child of <form>
- CKEditorError: ckeditor-duplicated-modules in next js