'React Native how to import a docx file from assets
Any ideas on why this doesn't work:
import Timesheet from './Timesheet.docx'
Works in the web browser, it gets imported and I can use the url to access the file later in the code.
When I use expo on android it returns as "module not found, file not found error"
Any thoughts on how to correct this?
Solution 1:[1]
you need to do something like this
in your assets folder create a index.js file then add the following (assuming your Timesheet.docx is in the same directory)
const timeSheet = require("./Timesheet.docx");
export { timeSheet };
In the file that need the timesheet
import { timeSheet } from './assets'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | obumoon |
