Comments (16)
@koistya quick question: the folder structure is obvious, but I can't seem to get the router to go to the blog index page: http://localhost:3000/blog/ or http://localhost:3000/blog/index but the router is working fine for the two article pages: http://localhost:3000/blog/test-article-one
Is there something I'm missing?
Thanks,
P
from react-firebase-starter.
+1
from react-firebase-starter.
Inside the app.js
file there is a hash table with routes in a form of a plain JavaScript object:
const routes = {};
During a build it is filled with routes based on the list of *.js
files in the src
folder. So that if you have /src/about.js
and /src/404.js
files for example, it will generate the following routes:
const routes = {
'/404', () => new Promise(resolve => require(['./404.js'], resolve),
'/about', () => new Promise(resolve => require(['./about.js'], resolve)
};
It uses webpack's code splitting feature to load missing components at run-time.
Then, when application loads into a browser, it extracts a route handler from that object given a URL path and executes it:
const action = routes[window.location.pathname] || routes['/404'];
const component = await action();
React.render(React.createElement(component), document.body);
Hope this helps :)
from react-firebase-starter.
from react-firebase-starter.
How does the navigation-link look like?
Is it so that I can navigate to "http://localhost:3000/#about" or "http://localhost:3000/about", I can't seem to get any of them to work.
from react-firebase-starter.
When you a regular navigation link such as <a href="/about">About</a>
this links needs to have a click handler which redirects a client to a new page without full page refresh and prevents the default behaviour (event.preventDefault()
). I will try to create an example how you can do it..
from react-firebase-starter.
I'd love to have an tutorial, too.
from react-firebase-starter.
With this routing system, is there a way to have a route, when activated, put the user at the top of the page? I've found that if I click on a link halfway down a screen, then the new view has the same placement.
Any help would be greatly appreciated.
from react-firebase-starter.
The routes do not work if the compiled/build folder is made to run on a non-nodeJS based server like Apache or WAMP. Only the page at the root '/' loads in a non-node serve. Is there a node server dependency for the routes to work?
Could you advice on how to fix this to make the routes work on a non node server?
from react-firebase-starter.
@vineesv you may want to change the pages
build step, so that it generates index.html
for each route. E.g. instead of /about.html
you need to have /about/index.html
.
from react-firebase-starter.
@philkeys have you tried this yet: https://www.npmjs.com/package/react-scroll
from react-firebase-starter.
It seems like BrowserSync doesn't understand that '/blog/index.html' should be accessed via '/blog' URL. I guess, it might be a good idea to generate /blog.html instead of /blog/index.html inside the build (dist) folder.
from react-firebase-starter.
Here is the logic that generates .html file names from React routes:
https://github.com/koistya/react-static-boilerplate/blob/master/utils/routes-loader.js
from react-firebase-starter.
@koistya thanks for the heads up - I'll try that!
from react-firebase-starter.
We need to locate the root of the site one level below the domain name, however the compilation process crashes when you include a path in routes-loader. We need:
http://domain.com/v1/index.html
How can this be done?
from react-firebase-starter.
@n8sabes I have refactored the routing, do you think it covers your use case? Check it out:
https://github.com/kriasoft/react-static-boilerplate/blob/master/docs/routing-and-navigation.md
If not, please don't hesitate to contact me with some more info about your scenario.
from react-firebase-starter.
Related Issues (20)
- An in-range update of @firebase/auth is breaking the build 🚨 HOT 2
- An in-range update of dotenv is breaking the build 🚨 HOT 1
- An in-range update of moment-timezone is breaking the build 🚨 HOT 1
- An in-range update of react is breaking the build 🚨 HOT 1
- An in-range update of eslint-config-prettier is breaking the build 🚨 HOT 1
- An in-range update of firebase-admin is breaking the build 🚨 HOT 1
- Migrate from JSS styles to Emotion
- Admin Access HOT 2
- error [email protected]: The engine "node" is incompatible with this module. Expected version "10". Got "12.13.0" HOT 2
- Subscriptions example
- Can't get CustomerChat working
- Cannot read property 'tap' of undefined with Typescript added
- [Feature Request] Scalars
- How to run react-firebase-starter in different GCP region
- [Question] What's the usual cost for maintaining this setup on gcloud+firebase? HOT 1
- How to pagination users or stories? HOT 1
- If I need a pure front-end frame, how can I refit it(react-firebase-starter) ?
- Issues with postgres connectivity running in dev mode HOT 1
- http://localhost:3000/login?error=connect%20ECONNREFUSED%20127.0.0.1%3A5432 HOT 1
- Is this repo still maintained ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-firebase-starter.