OOB Spfx version 1.13.1 break while using react-router-dom
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
not applicable
Developer environment
Windows
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [ ] 💥 Microsoft Edge
- [X] 💥 Google Chrome
- [ ] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [ ] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
- browser version
- SPFx version : 1.13.1
- Node.js version : 14.17.5
- react-router-dom : 6.2.1
- etc
Describe the bug / error
upon running gulp buld the following error comes up
[16:04:24] Error - [tsc] node_modules/react-router/index.d.ts(151,74): error TS1110: Type expected. [16:04:24] Error - [tsc] node_modules/react-router/index.d.ts(151,83): error TS1005: '}' expected. [16:04:24] Error - [tsc] node_modules/react-router/index.d.ts(151,94): error TS1128: Declaration or statement expected. [16:04:24] Error - [tsc] node_modules/react-router/index.d.ts(151,96): error TS1161: Unterminated regular expression literal. [16:04:24] Error - 'tsc' sub task errored after 3.85 s
Steps to reproduce
- create oob spfx webpart project with yo
- npm i react-router-dom
- add import { HashRouter, Route } from "react-router-dom" to the tsx file
- run gulp build and it breaks with the above mentioned errror
Expected behavior
it should build and routing should work Here is package-lock file in case you need to debug it
C:\code\route pkgLock.txt
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Hi @techakki81 - thank you for reporting this one!
As I can see from the react-router repo, v6 is based on TypeScript v4 with target set to ES2020 and React v17. Both of those are not supported by SPFx yet.
I would recommend to try v5 instead.
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues