sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

OOB Spfx version 1.13.1 break while using react-router-dom

Open techakki81 opened this issue 4 years ago • 3 comments

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

  1. create oob spfx webpart project with yo
  2. npm i react-router-dom
  3. add import { HashRouter, Route } from "react-router-dom" to the tsx file
  4. 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

techakki81 avatar Jan 18 '22 15:01 techakki81

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar Jan 18 '22 15:01 ghost

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.

AJIXuMuK avatar Jan 18 '22 16:01 AJIXuMuK

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

ghost avatar Jan 28 '22 18:01 ghost