By creating a simple ‘hello world’ example application first in vanilla Javascript, and then in Preact without any tools, we’ll learn what type of problems Preact is solving for us and how is works at a low level. Then we’ll switch to a Webpack + Babel setup we’ll cover some fundamental concepts such as, which imports we need, how to create a component, how to use JSX and finally how to render our component into a target element in a web page.

index.js

import {h, render} from 'preact';
import App from './components/App'; render(<App />, document.querySelector('main'));

Here, we must import 'h' even we don't use it. It allows preact convert JSX to JS render to the DOM.

App.js:

import {h} from 'preact';

const App = () => {
return (
<div>
Hello World!!!
</div>
);
}; export default App;

[PReact] Create a Hello World App with Preact的更多相关文章

  1. How to create a Maven web app and deploy to Tomcat - fast

    原文地址: http://www.blogjava.net/sealyu/archive/2010/01/08/308706.html Procedure Prerequisites and Assu ...

  2. [PReact] Reduce the Size of a React App in Two Lines with preact-compat

    Not every app is greenfield, and it would be a shame if existing React apps could not benefit from t ...

  3. Create Fiori List App Report with ABAP CDS view – PART 2

    In the Part 1 blog, we have discussed below topics CDS annotations for Fiori List Report. How to cre ...

  4. Create Fiori List App Report with ABAP CDS view – PART 1

    From Create Fiori List App Report with ABAP CDS view – PART 1 In this blog, I am going to show How C ...

  5. mvn archetype:create报错解决办法

    执行下列命令:mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app -X  会报错: 此时将archetype:cr ...

  6. 404 & 401 Errors with the App Management Service

    from:http://blogs.technet.com/b/sharepoint_-_inside_the_lines/archive/2013/06/23/404-amp-401-errors- ...

  7. In App Purchase Statuses

    In App Purchase StatusesThe following are the available states that can be assigned to your in app p ...

  8. iphone Dev 开发实例9:Create Grid Layout Using UICollectionView in iOS 6

    In this tutorial, we will build a simple app to display a collection of recipe photos in grid layout ...

  9. [转] Creating a Simple RESTful Web App with Node.js, Express, and MongoDB

    You can find/fork the sample project on GitHub Hey! This and all my other tutorials will soon be mov ...

随机推荐

  1. 韦东山ARM裸机笔记(2)--vi编辑器

    VI编辑器(Visual Interface--可视化接口) 一.Linux下的一个文本编辑器,所具备的基本功能: 打开.新建.保存文件 光标移动 文本编辑 (多行间 | 多列间)复制.粘贴.删除 查 ...

  2. rune 切片 go

    package main import ( "fmt" ) func main() { var s = "go程序``**//;;''[p]=-\\&|@#$%^ ...

  3. oracle 10g standby database 实时应用 redo 数据

    -------physical standby database: real-time apply 须要配置 standby redo log: 启用实时应用, 日志应用服务会直接应用接收的redo ...

  4. js--27门面模式

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  5. shell-手机屏幕录制

    今天在做android联系的时候,想要把自己写的demo效果记录下来.在网上发现了录制手机屏幕的方法,如下 adb shell screenrecord /sdcard/demo.mp4 解释 adb ...

  6. 65.十一级指针实现百万qq号的增删查改以及排序写入

    运行结果: 内存使用情况: 写入文件排序好的数据: 创建文件地址以及创建十一级指针 char *path = "QQ.txt"; char *sortpath = "QQ ...

  7. iTOP-4412 nfs文件系统启动

    kernel command line type: 普通文件系统(本地)启动:root=/dev/mmcblk0p2 rootfstype=ext4 init=/linuxrc console=tty ...

  8. Python中对于GIL全局解释器锁的一点理解

    GIL全局解释器锁 python最初开发时,开发人只考虑到了单核CPU的,为解决多线程运算之间的数据完整性和状态同步选择了加锁的方式.即GIL锁. 而目前的CPU都有多个核心,在运行python的某个 ...

  9. 洛谷 P1724 东风早谷苗

    洛谷 P1724 东风早谷苗 题目描述 在幻想乡,东风谷早苗是以高达控闻名的高中生宅巫女.某一天,早苗终于入手了最新款的钢达姆模型.作为最新的钢达姆,当然有了与以往不同的功能了,那就是它能够自动行走, ...

  10. CMake编译Makefile

    以编译Libtif文件为例: 你可以用CMake编译libtiff,超简单,两个步骤. 参考文章 CharlesSimonyi,libtiff库的问题的答复