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.

Compiled HTML looks faulty: __source / __self [object Object]

See original GitHub issue

Hey guys!

I’m sitting with a freshly installed create-react-app which I’ve converted to Preact with the simple steps. I get this weird issue when compiling my jsx files with Preact, and can’t really find the root of cause.

My Index.jsx

import { h, render } from 'preact';
import registerServiceWorker from './utilities/registerServiceWorker';

render(
  <div className="app">
    <p className="app-intro">
      To get started, edit <code>src/App.js</code> and save to reload.
    </p>
  </div>,
  document.getElementById('root')
);

registerServiceWorker();

The compiled HTML file

<div class="app" __source="[object Object]" __self="[object Object]">
  <button class="app-intro" __source="[object Object]" __self="[object Object]">
To get started, edit <code __source="[object Object]" __self="[object Object]">src/App.js</code> and save to reload.
  </button>
>

Does anybody have an idea of what might could be the problem?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
Kanayecommented, Apr 5, 2018

Okay create-react-app uses the babel plugins: transform-react-jsx-source and transform-react-jsx-self by default in none-production builds. Preact doesn’t support those “special” attributes and just adds them as a stringified version to the dom. In a production build those attributes won’t exist.

If you are using create-react-app to have an easy quick start, you can also take a look at preact-cli.

0reactions
mthinescommented, Apr 6, 2018

I configured my babel like this, and it works as expected.

"presets": [
  "react",
  "es2015"
],
"plugins": [
  "transform-es2015-destructuring",
  "transform-object-rest-spread",
  [
    "transform-react-jsx",
    {
      "pragma": "h"
    }
  ]
]

Thanks for the help guys! 💪

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compiled HTML looks faulty: __source / __self ... - GitHub
I get this weird issue when compiling my jsx files with Preact, and can't really find the root of cause. My Index.jsx. import...
Read more >
The 10 Most Common JavaScript Issues Developers Face
If you need help figuring out why your JavaScript isn't working, consult this list of the 10 most common JavaScript issues from a...
Read more >
Content Configuration - Tailwind CSS
This guide covers everything you need to know to make sure Tailwind generates all of the CSS needed for your project. ​. Configuring...
Read more >
Emscripten Compiler Frontend (emcc)
The input file(s) can be either source code files that Clang can handle (C or C++), object files (produced by emcc -c ),...
Read more >
Troubleshooting CI/CD - GitLab Docs
GitLab provides several tools to help make troubleshooting your pipelines easier. This guide also lists common issues and possible solutions.
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