hookrouter
hookrouter copied to clipboard
Error on setBasePath method
Hi. I'm using the setBasePath method to notify hookrouter that I'm using a non-root base path. I'm using create-react-app and hookrouter. Trying start in dev and and execute my build now throw a TypeError: Object(...) is not a function error. Please note that I also changed my homepage in package.json to the non-root route. I assume I'm doing something wrong. Please help!
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import {setBasePath} from 'hookrouter'
require('typeface-montserrat')
/* Tell router to use a non-root path */
setBasePath('/ARBQ/informal-offers')
/* Attach react app to the DOM */
ReactDOM.render(<App />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
package.json
{
"name": "informal-offers-signin",
"version": "1.1.0",
"homepage": "/ARBQ/informal-offers/",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.4.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"hookrouter": "^1.2.3",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.1",
"typeface-montserrat": "0.0.75"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"react-test-renderer": "^16.13.0"
}
}
Errors
TypeError: Object(...) is not a function
./src/index.js
src/index.js:10
7 | require('typeface-montserrat')
8 |
9 | /* Tell router to use a non-root path */
> 10 | setBasePath('/ARBQ/informal-offers')
11 |
12 | /* Attach react app to the DOM */
13 | ReactDOM.render(<App />, document.getElementById('root'));
__webpack_require__
/home/dave/Documents/informal-offers-signin/webpack/bootstrap:785
782 | };
783 |
784 | // Execute the module function
> 785 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
| ^ 786 |
787 | // Flag the module as loaded
788 | module.l = true;
fn
/home/dave/Documents/informal-offers-signin/webpack/bootstrap:150
147 | );
148 | hotCurrentParents = [];
149 | }
> 150 | return __webpack_require__(request);
| ^ 151 | };
152 | var ObjectFactory = function ObjectFactory(name) {
153 | return {
1
http://localhost:3000/static/js/main.chunk.js:1891:18
__webpack_require__
/home/dave/Documents/informal-offers-signin/webpack/bootstrap:785
782 | };
783 |
784 | // Execute the module function
> 785 | modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId));
| ^ 786 |
787 | // Flag the module as loaded
788 | module.l = true;
checkDeferredModules
/home/dave/Documents/informal-offers-signin/webpack/bootstrap:45
42 | }
43 | if(fulfilled) {
44 | deferredModules.splice(i--, 1);
> 45 | result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
| ^ 46 | }
47 | }
48 |
webpackJsonpCallback
/home/dave/Documents/informal-offers-signin/webpack/bootstrap:32
29 | deferredModules.push.apply(deferredModules, executeModules || []);
30 |
31 | // run deferred modules when all chunks ready
> 32 | return checkDeferredModules();
| ^ 33 | };
34 | function checkDeferredModules() {
35 | var result;
(anonymous function)
http://localhost:3000/static/js/main.chunk.js:1:97