question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Newest updates to Async Loader cause error message if App component is in /routes

See original GitHub issue

Do you want to request a feature or report a bug?

A bug

What is the current behaviour?

Currently the following is written to the console in the browser:

Uncaught Error: Undefined component passed to createElement()

You likely forgot to export your component or might have mixed up default and named imports <#text dangerouslySetInnerHTML="[object Object]" />

As far as I can tell, this does not cause any problems in the app, just the error message on every reload.

If the current behaviour is a bug, please provide the steps to reproduce.

Using the default Preact template, move App.js from /components to /routes. Start the dev server and check the console in your browser.

What is the expected behaviour?

That no error is thrown. If I downgrade to 3.0.0-rc.14 or don’t place App.js in /routes everything is fine again.

Please mention other relevant information.

If there’s an actual reason why App.js needs to be outside of /routes I can, of course, move it, though it is my personal preference to have it there as I generally think it makes the most sense.

Environment Info:
  System:
    OS: Linux 5.6 Manjaro Linux
    CPU: (4) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 14.3.0 - /usr/bin/node
    Yarn: 1.22.4 - /usr/bin/yarn
    npm: 6.14.5 - /usr/bin/npm
  Browsers:
    Firefox: 78.0.1
  npmPackages:
    preact: ^10.3.2 => 10.4.5 
    preact-cli: ^3.0.0-rc.16 => 3.0.0-rc.16 
    preact-render-to-string: ^5.1.4 => 5.1.9 
    preact-router: ^3.2.1 => 3.2.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
reznordcommented, Jul 6, 2020

If you feel that the components are tend to change often but not app.js, then you can always leave it in src/ which won’t create any issues 🙃

0reactions
micahjoncommented, Mar 9, 2022

For what it’s worth, I’ve found I get this same error if Router is top-level and isn’t wrapped in another HTML element (like <div id="preact_root">), e.g.

// app.tsx
const App: FunctionalComponent = () => {
  return (
    <Router>
      <Route path="/" component={Home} />
      <Route path="/profile/" component={Profile} user="me" />
      <Route path="/profile/:user" component={Profile} />
      <NotFoundPage default />
    </Router>
  );
};

I’m fairly new to the React ecosystem, so maybe this is obvious, but figured it’d be worth noting in case others were experiencing the same thing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Handle Async Data Loading, Lazy Loading, and Code ...
Notice that the component renders before the data is loaded. The advantage with asynchronous code is that it won't block the initial render....
Read more >
The pipe 'async' could not be found - Stack Overflow
I get the error in the console. The problem arises only when I try to use async in blog. component. html file.
Read more >
Route Loaders - React Location - TanStack
Fetch data from a server; Delay the loading of a route until an asynchronous action has been completed; Prepare the route to be...
Read more >
Suspense for Data Fetching (Experimental) - React
Even with await , asynchronous code is often error-prone. Suspense feels more like reading data synchronously — as if it were already loaded....
Read more >
Loading / Error Substates - Routing - Ember Guides
The Ember Router allows you to provide feedback that a route is loading, as well as when an error occurs in loading a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found