25 lines
No EOL
1.5 KiB
Markdown
25 lines
No EOL
1.5 KiB
Markdown
router
|
|
|
|
- When using react router if we try to add direct links like using anchor tag it wont work in build ie production mode so its better to use `useNavigate` method of `react-router-dom`.
|
|
- Alternatively if we really want to do that manually its possible with live-server command but with some modification in configs
|
|
Create `app.js` and use `npm init -y` and `npm i live-server` and add following config in app.js
|
|
https://github.com/ritwickdey/vscode-live-server/issues/72
|
|
```js
|
|
var liveServer = require("live-server");
|
|
|
|
var params = {
|
|
port: 8181, // Set the server port. Defaults to 8080.
|
|
host: "0.0.0.0", // Set the address to bind to. Defaults to 0.0.0.0 or process.env.IP.
|
|
root: ".", // Set root directory that's being served. Defaults to cwd.
|
|
open: false, // When false, it won't load your browser by default.
|
|
ignore: 'scss,my/templates', // comma-separated string for paths to ignore
|
|
file: "index.html", // When set, serve this file (server root relative) for every 404 (useful for single-page applications)
|
|
wait: 1000, // Waits for all changes, before reloading. Defaults to 0 sec.
|
|
// mount: [['/components', './node_modules']], // Mount a directory to a route.
|
|
logLevel: 2, // 0 = errors only, 1 = some, 2 = lots
|
|
middleware: [function(req, res, next) { next(); }] // Takes an array of Connect-compatible middleware that are injected into the server middleware stack
|
|
};
|
|
liveServer.start(params);
|
|
|
|
```
|
|
- Or maybe use HashRouter instead of Browserrouter. that may resolve issue |