Closed motleydev closed 7 years ago
I have a serious of routes created that render to the page with named route properties. The rendered react looks like this:
<Link route="blog"> <a onClick=bound linkClicked()>Blog</a> </Link>
Which is defined by my menu.js component here:
import React from 'react' import Link from 'next/link' import {menu} from './routes' export default () => ( <ul> { menu.map( (menuchen, index) => <li key={index}><Link route={menuchen.path}> <a>{menuchen.title}</a> </Link></li>) } </ul> )
But when I click on the link the client console complains about a url parameter. Parameter 'url' must be a string, not undefined
url
Parameter 'url' must be a string, not undefined
I define the routes.js here:
routes.js
const routes = module.exports.routes = require('next-routes')() const menu = module.exports.menu = [ { title: "Blog", path: "blog" } ] menu.forEach(menuchen => {routes.add(menuchen.path, menu.path, "index")})
and my server.js setup looks like this:
server.js
const next = require('next') const routes = require('./comps/menu/routes').routes const app = next({dev: process.env.NODE_ENV !== 'production'}) const handler = routes.getRequestHandler(app) const express = require('express') app.prepare().then(() => { express().use(handler).listen(3000) })
Missed the part about importing <Link /> from the routes file. Needed some reconstruction but works now.
<Link />
I have a serious of routes created that render to the page with named route properties. The rendered react looks like this:
Which is defined by my menu.js component here:
But when I click on the link the client console complains about a
url
parameter.Parameter 'url' must be a string, not undefined
I define the
routes.js
here:and my
server.js
setup looks like this: