測試 React Material-UI 並且實作下載功能。
- react-router-dom
- material-ui/core
- material-ui/icons
- react-pdf/renderer v2.0.17
- 將專案複製到本機 (兩種方法)
(1) 打開終端機輸入
git clone https://github.com/aoigj100a/form-lab-react
(2) 點選 download ZIP 下載
- 進入專案資料夾安裝工具包
打開終端機輸入
npm install
- 啟動專案
安裝完畢之後在終端機輸入
npm start
- Error “render is a Node specific API” when using the module @react-pdf/renderer
npm i @react-pdf/renderer
出現錯誤 ERESOLVE unable to resolve dependency tree 因 npm7 預設"peerDependencies are installed by default" ->npm i @react-pdf/renderer --force
安裝成功🆗✔️- 使用usePDF 觸發 Error: Invalid hook call. Hooks can only be called inside of the body of a function component -> 將函示元件中 hook 位置調整🆗✔️
- 使用 PDFDownloadLink 會觸發 Error: Argument appears to not be a ReactComponent -> 發現只需使用 react-PDF中的元件來建立檔案,不要混用 Material-UI 元件便可修復問題🆗✔️
- material-ui create pdf