Open daniramdani opened 7 years ago
import { resolve } from 'universal-router'
const routes = {
path: '/users',
children: [
{ path: '/', action() { return 'Users' } },
{ path: '/create', action() { return 'Create User' } },
{ path: '/add', action() { return 'Add User' } },
{ path: '/:id', action(context) { return `User #${context.params.id}` } },
]
}
resolve(routes, '/users/1').then(result => {
document.body.innerHTML = result
})
Playground: https://jsfiddle.net/frenzzy/pg0ouyxm/
Add by analogy with other routes
Hi koistya, I'm newbie in React JS, I'm using SB Admin React Starter Kit to create my app, I wish to create kind REST routes :
http://example.com/users http://example.com/users/1 http://example.com/users/create http://example.com/users/add …
But I can't figure out how to make it, may you can help me to solve my problem ?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.