preactjs-templates / simple Goto Github PK
View Code? Open in Web Editor NEWA simple, minimal "Hello World" template for Preact CLI
Home Page: https://github.com/developit/preact-cli
A simple, minimal "Hello World" template for Preact CLI
Home Page: https://github.com/developit/preact-cli
I use preact-cli
with the simple
template:
preact create simple preact-bug-h
cd preact-bug-h
preact build
I verified that Hello, World!
is displayed in the browser — as expected.
TypeError: h is not a function
Edit index.js
and paste the following line before export default class App ...
:
const h = 0;
Run preact build
, get the following result:
TypeError: h is not a function
method: JkW7
at: /.../preact-bug-h/index.js:9:4
This error is quite explicit, but still it's not super obvious why h
cannot be used here.
Edit index.js
, and now define h
to be a function, for example:
const h = () => {};
Run preact build
, is finishes successfully. Open the result page in browser — now it appears to be empty.
I'm sorry if this is a silly issue and thank you for looking into it. I also hope it's an appropriate place to raise the issue.
The default index.js
only imports Component
:
import { Component } from 'preact';
As I understand, h
is injected when JSX is rendered by babel. This happens behind the scene, and we probably want developers to not worry about the mechanics of this process. However, I'm afraid that the chosen name might be a bit too common, especially in quick prototypes. Developers new to the ecosystem might get disoriented when their project suddenly stops working.
Maybe the template/index.js
can be updated to also import h
? The ticking clock demo on the getting started page does that, even though it's not being explicitly used. I personally don't think it's the best solution, but at least it gives a hint.
Maybe preact-cli can be reconfigured by default to use a different name, not h
?
Maybe preact-cli documentation can be improved to mention the use of h
?
Th name isn't replaced when creating an app using:
preact create simple app
It's true for all the file I think, at least it's the case in the index.html as well as the manifest.
Version 2.0.1
When initialised with npx preact-cli create simple myproject
the artifacts are organised in a way that results in 404 on static assets and manifest.json
. To solve this one has to move assets
directory and manifest.json
into src
.
Migrate from eslint-config-synacor to official ESLint configuration for Preact. I will be glad to make PR if this migration is reasonable.
Line 9 in d806565
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.