D
D
Dmitry2018-02-11 16:45:48
React
Dmitry, 2018-02-11 16:45:48

How to pass component by reference in production build?

Good afternoon.
I have a list of routes as an array:

[
  { path: '/', component: components.AppComponent, exatct: true, tag: Route },
  { path: '/dashboard', component: components.DashboardComponent, exatct: true, tag: PrivateRoute }
]

Then I go through the array and form something like:
let rendered = routes.map((a, idx) => {
  const Tag = a.tag;
  const props = a;
  return <Tag {...props} />
})

Everything is fine in the dev mode, but when I make a build, an error appears in the console, which cannot be read in the prod mode.
5a8048410da73970170236.png
If instead I just render there is no error, by some miracle in the minified mode, instead of Route, undefined arrives in the property tag, but at the same time, the application renders the correct route and the correct component.
What could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question