aurelia / templating

An extensible HTML templating engine supporting databinding, custom elements, attached behaviors and more.
MIT License
116 stars 103 forks source link

Route pointing to @noView with React component returns TypeError #550

Open peacechen opened 7 years ago

peacechen commented 7 years ago

I'm submitting a bug report

I've written an app that contains React components. However the Aurelia Router doesn't like pages that have @noView, returning TypeError.

415 touched on this but there doesn't seem to be a resolution on it. getViewStrategy is mentioned but it's not clear whether it plays nice with Aurelia's router.

The flow looks like:

.------------------.      .---------------.
|  Landing Page:   |  --> | React         |  --> ....
| Aurelia template |      |  Component    |
`------------------'      `---------------'

Please tell us about your environment:

Current behavior: Route with @noView results in TypeError.

Expected/desired behavior:

EisenbergEffect commented 7 years ago

The main issue is that Aurelia doesn't know how to insert the React component into the router-view.

peacechen commented 7 years ago

Is there any work-around, short term or long term?

EisenbergEffect commented 7 years ago

You can use an @inlineView with a single element that you render the React component into. You could also create a custom view strategy that returned an Aurelia View that owned the React component's DOM element (though this is a bit more involved). The second option is probably the best way to handle it because it could be applied via a decorator.