troch / route-node

A package to create a tree of named routes
MIT License
20 stars 15 forks source link

buildPath() and getPath() behavior with non-existent route names #9

Closed motet-a closed 6 years ago

motet-a commented 7 years ago

I can't see any test with buildPath() or getPath() called with an non-existent route name. I think it makes sense to return null here, but in higher-level packages like react-router5, this should throw an error:

<BaseLink routeName="badroutename" />

Currently, the underlying <a> element is created with href="null", and I don’t think I’m the only fool who mistypes route names.

(Okay, I probably should have created this issue in react-router5 :upside_down_face:)

motet-a commented 7 years ago

Of course, I’m ready to contribute and write those tests.

troch commented 7 years ago

I wouldn't throw an error to avoid disturbing the rendering process, but a console.error in react-router5 would be ideal.