react-router-bootstrap icon indicating copy to clipboard operation
react-router-bootstrap copied to clipboard

react-router-dom v 6.x?

Open sheam opened this issue 5 years ago • 18 comments

When I try to run this with react-router-dom vs 6.0.1 I get the following compile error:

TypeError: (0 , _reactRouterDom.withRouter) is not a function
./node_modules/react-router-bootstrap/lib/LinkContainer.js
C:/Users/sheam/Code/hs-image-manager/node_modules/react-router-bootstrap/lib/LinkContainer.js:155
  152 |   strict: false,
  153 |   activeClassName: 'active'
  154 | };
> 155 | exports.default = (0, _reactRouterDom.withRouter)(LinkContainer);
View compiled
__webpack_require__
C:/Users/sheam/Code/hs-image-manager/webpack/bootstrap:856
  853 | 
  854 | __webpack_require__.$Refresh$.init();
  855 | try {
> 856 | 	modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
      | ^  857 | } finally {
  858 | 	__webpack_require__.$Refresh$.cleanup(moduleId);
  859 | }
View compiled

My code looks like this:

function App()
{
    return (
        <div className="App">
            <Router>
                <Navbar bg="light" expand="lg">
                    <Container>
                        <Navbar.Brand href="#home">HS Image Manager</Navbar.Brand>
                        <Navbar.Toggle aria-controls="basic-navbar-nav"/>
                        <Navbar.Collapse id="basic-navbar-nav">
                            <Nav className="me-auto">
                                <LinkContainer to="/">
                                    <Nav.Link>Upload</Nav.Link>
                                </LinkContainer>
                                <LinkContainer to="/manage">
                                    <Nav.Link>Manage</Nav.Link>
                                </LinkContainer>
                            </Nav>
                        </Navbar.Collapse>
                    </Container>
                </Navbar>

                <Routes>
                    <Route path="/" element={<UploadPage/>}/>
                    <Route path="/manage" element={<ManagePage/>}/>
                </Routes>
            </Router>
        </div>
    );
}

I am using CRA typescript template and my package.json looks like this:

{
  "name": "hs-image-manager",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "@types/jest": "^26.0.15",
    "@types/node": "^12.0.0",
    "@types/react": "^17.0.0",
    "@types/react-dom": "^17.0.0",
    "@types/react-router-bootstrap": "^0.24.5",
    "bootstrap": "^5.1.3",
    "react": "^17.0.2",
    "react-bootstrap": "^2.0.2",
    "react-dom": "^17.0.2",
    "react-router-bootstrap": "^0.25.0",
    "react-router-dom": "^6.0.1",
    "react-scripts": "4.0.3",
    "sass": "^1.43.4",
    "typescript": "^4.1.2",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Is this compatible with RRD 6+?

sheam avatar Nov 07 '21 19:11 sheam

I just hit this problem too

margori avatar Nov 08 '21 22:11 margori

Same Issue here

ruizaj13 avatar Nov 11 '21 18:11 ruizaj13

I don't use this myself, but probably worth resurrecting @mxschmitt's branch to add in the support

kyletsang avatar Nov 11 '21 23:11 kyletsang

Bump, I have this issue too.

DjovDev avatar Nov 16 '21 15:11 DjovDev

I also don't use it myself, didn't use react-router for a few years now. We can merge #260, but I don't feel comfortable, without knowing exactly if it's working as intended.

mxschmitt avatar Nov 16 '21 15:11 mxschmitt

I also don't use it myself, didn't use react-router for a few years now. We can merge #260, but I don't feel comfortable, without knowing exactly if it's working as intended.

I can help out here. Let's merge it 😄

kyletsang avatar Nov 16 '21 17:11 kyletsang

I see that PR is merged, thank you! :heart: when is this fix expected to be released?

ODushyn avatar Nov 19 '21 10:11 ODushyn

I see that PR is merged, thank you! ❤️ when is this fix expected to be released?

Still need to resolve some build issues

kyletsang avatar Nov 19 '21 20:11 kyletsang

Hmmm, am I the only one having trouble with the beta? I get this error:

Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

Error messages from react in the console point to my usage of LinkContainer:

                        <LinkContainer to={moreInfoPath}>
                            <Nav.Link>
                                {aboutText}
                            </Nav.Link>

                        </LinkContainer>

ariccio avatar Nov 22 '21 23:11 ariccio

Sorry, there's still some build output issues. Will investigate later

kyletsang avatar Nov 22 '21 23:11 kyletsang

Please try 0.26.0-beta.2

kyletsang avatar Nov 23 '21 01:11 kyletsang

Aaaaand, it looks like beta.2 works!

ariccio avatar Nov 23 '21 18:11 ariccio

The LinkContainer issue was exactly the problem. Thanks so much!

ariccio avatar Nov 23 '21 18:11 ariccio

Same here, I plugged it in and no issues at all.

Thanks everyone

From: Alexander Riccio @.> Sent: Tuesday, November 23, 2021 1:55 PM To: react-bootstrap/react-router-bootstrap @.> Cc: Subscribed @.***> Subject: Re: [react-bootstrap/react-router-bootstrap] react-router-dom v 6.x? (Issue #266)

Aaaaand, it looks like beta.2 works!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/react-bootstrap/react-router-bootstrap/issues/266#issuecomment-977015103 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AARIOHHFR7KUZLWWHL7IMZDUNPPOVANCNFSM5HRFPXBQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . https://github.com/notifications/beacon/AARIOHA3DHKLBEC737RUKGLUNPPOVA5CNFSM5HRFPXB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHI6BCPY.gif

glassputan avatar Nov 23 '21 20:11 glassputan

Wow that was a weird way for the error to manifest itself!

Beta 2 did fix everything for me too. Thanks!

sheam avatar Nov 24 '21 01:11 sheam

Thanks everybody for testing. Thanks @mxschmitt for getting this off the ground 👍

kyletsang avatar Nov 24 '21 19:11 kyletsang

Anybody else having new issues with navbar tabs not updating on navigation?

ariccio avatar Nov 28 '21 02:11 ariccio

(nevermind, I suspect I'm doing the dynamic routes subtly wrong!)

ariccio avatar Dec 09 '21 17:12 ariccio