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
- React issue with updating state during re-render
- React not re-rendering component after page refresh, even if the state changes
- Mongoose Schema User Submitted Date Value
- Problem to request data from express server with Axios
- Videos In React Going Fullscreen
- What's the way to update dynamic state using React hooks?
- React: window.scrollTo(0,0) on component render EACH time
- Webpack.config.js process.env.NODE_ENV not workinkg. - ReactJS -
- Enzyme check if component mounted without errors on prop types
- Unable to change value of component programmatically using useState
- Setting multiple parameters on breakpoint in MUI v5
- useEffect missing dependency error for simple function
- How to play audio by clicking a specific button with onKeyDown on React?
- Storybook webpack will not load scss files
- How to remove label on hover of react icon file?
- Ionic React, error "Argument of type is not assignable" for correct code
- Logic for rotating a square
- How to enter a value into a react-select component in componentDidMount
- Draw a Constant Line in D3.js over another Line Graph
- Is there a better way to put classes into html and body tags in next.js?
- How to dynamically create an array of buttons in React using MonogoDB?
- React on Submit shows no data in console
- Unable to increase size(height, width) of react-phone-input-2
- React constructor isn't called when update a prop from parent component
- How to implement error boundary in react with server side rendering in nextjs?
- How to link/reference multiple scripts in an html file with react (WITHOUT NODE.js)?
- Howto add pagination with axios get request in Reactjs
- On focusing number box (input type="number"), the defaultValue(0) should be cleared out and it should be blank in Reactjs
- How to design Redux stores and actions?
- React components inside Angular 1.4 application