question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi guys! I’m loving this framework, many compliments!

Unfortunately at the moment I’m experiencing a strange problem, I cannot make the router work. This is my code:

'use strict'

const choo = require('choo')
const html = require('choo/html')

const view1 = (state, prev, send) => {
  return html`<h1>Hello!</h1>`
}

const view2 = (state, prev, send) => {
  return html`<h1>World!</h1>`
}

const app = choo()
app.router([
  ['/', view1],
  ['/world', view2]
])

const tree = app.start()
document.body.appendChild(tree)

If I go into the brawser at the url everything is ok, If I go to url/world I get a 404. Even if I set a default route (I tried both budo and bankai to compile the code). Probably I’m lost in a glass of water, can you help me? Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
josephluckcommented, Jan 17, 2017

@delvedor - this isn’t a choo specific issue, but an issue for single page apps in general. http://jaketrent.com/post/pushstate-webpack-dev-server/ there’s a good article explaining how to use webpack dev server.

Personally I’ve found budo --pushstate more than adequate during dev, and a simple express server catching all routes to serve index.html for production.

1reaction
JRJurmancommented, Jan 16, 2017

Using budo, I was able to get it to work by passing in the option --pushstate. This causes budo to always serve index.html (and not 404). I don’t know if there’s a way for choo to expose the routes to budo, but what I’ve done in the past is have my build scripts build an index.html at each route (e.g. /index.html, /hello/index.html, /world/index.html)

I’ve run into this issue in React as well, not sure if this is the best solution, but meh, it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use a Router - The Home Depot
1. What does a router do? It allows you to make:; Customized cuts to shape the edges of a board 2. You can...
Read more >
What is a Router? - Definition and Uses - Cisco
A router receives and sends data on computer networks. Routers are sometimes confused with network hubs, modems, or network switches. However, routers can ......
Read more >
6 Beginner Ways to Use a Woodworking Router - Bob Vila
Routers can be used to cut patterns, grooves, and designs across multiple pieces of wood. For instance, if you have a broken table...
Read more >
What Is a Router and How to Use One: The Beginner's FAQ
Routers are the nodes that make up a computer network like the internet. The router you use at home is the central node...
Read more >
How to Check Data Usage on a Wi-Fi Router - Lifewire
How Do I Check My Wi-Fi Usage? ... Most home routers have some form of built-in data tracking. You can access that via...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found