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.

h() missing from README.md example?

See original GitHub issue

The README.md example says to use

import { h, render } from 'preact';

render((
    <div id="foo">
        <span>Hello, world!</span>
        <button onClick={ e => alert("hi!") }>Click Me</button>
    </div>
), document.body);

but this makes h an unused import… should that be render(h(....))?

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
ForsakenHarmonycommented, Jan 26, 2017

no, the generated code contains h

import { h, render } from 'preact';

render((
    <div id="foo">
        <span>Hello, world!</span>
        <button onClick={ e => alert("hi!") }>Click Me</button>
    </div>
), document.body);

will be transpiled to

import { h, render } from 'preact';

render((
    h("div", {id: "foo"}, 
        h("span", null, "Hello, world!"), 
        h("button", {onClick:  e => alert("hi!")}, "Click Me")
    ),
), document.body);

More on jsx (h replaces React.createElement, you could also use preact.h of course)

2reactions
Pomaxcommented, Jan 27, 2017

Thanks, I’ll definitely give that a read!

But, as someone who is super comfortable with JSX (I’ve written several longreads about react with jsx back when we were on React 0.12) and despite that had never heard of hyperscript. Tech stack bubbles are weird =)

Read more comments on GitHub >

github_iconTop Results From Across the Web

h() missing from README.md example? · Issue #521 - GitHub
The README.md example says to use import { h, render } from 'preact'; render(( Hello, world! alert("hi!") }>Click Me ), document.body); ...
Read more >
README.md file missing on github - Stack Overflow
Today I noticed that the README file is missing. I checked my commits and couldn't find anything related to README there.
Read more >
master · examples / Excel 2007 The Missing Manual · GitLab
README.md ... Excel 2007: The Missing Manual, by Matthew MacDonald ... The following applies to example files from material published by ...
Read more >
Basic Syntax - Markdown Guide
Heading Best Practices. Markdown applications don't agree on how to handle a missing space between the number signs ( # ) and the...
Read more >
7217f03fbf9a14dff84acd717703...
... sebastian Keep macro SIZEOF_VOID_P out of expat_config.h(.in) for ... 2021-05-22 sebastian README.md: Make CMake config mode example ...
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