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. PatentTips - Improving security in a virtual machine host

    BACKGROUND Computer viruses are a common problem for computer users. One typical mode of attack is t ...

  2. [Java开发之路](16)学习log4j日志

    1. 新建一个Javaproject.导入Jar包(log4j-1.2.17.jar) Jar包下载地址:点击打开链接 2. 配置文件:创建并设置log4j.properties # 设置 log4j ...

  3. javafx spring

    javafx spring http://files.cnblogs.com/files/rojas/airhacks_control.zip

  4. 根据点画线java

    package com.yang; import java.awt.Color; import java.awt.Graphics; import java.util.ArrayList; impor ...

  5. DG Cascade Standby

    SUMMARY 1. logical standby不支持cascading standby 2. 11.2.0.2之前版本cascading standby不支持RAC 3. 11.2.0.3之前版 ...

  6. php学习笔记5

    PHP 常量 常量值被定义后,在脚本的其他任何地方都不能被改变. 一个常量由英文字母.下划线.和数字组成,但数字不能作为首字母出现. (常量名不需要加 $ 修饰符). 注意: 常量在整个脚本中都可以使 ...

  7. 从数据库中生成XML文件

    前台页面<%@ page language="java" contentType="text/html; charset=utf-8" pageEncod ...

  8. Java String对象的经典问题

     先来看一个样例,代码例如以下:  public class Test {       public static void main(String[] args) {           Strin ...

  9. 关于hadoop hdfs里文件为啥上一级大小是0,进去又有大小问题解释?

    问题 好像跟平时的理解不一样,外边是0,进去就是有大小了? 答:hdfs具体文件是针对具体文件的,不是文件目录.    文件夹大小为0,不是里面所有内容为0.

  10. git 当出现 devirge 时,一个是commit的提交顺序不对

    进入新分支1.git pull origin branchname 2.修改 3.git add . 4.git commit  5. git pull 6.git push 出现分歧要,就版本回退, ...