【[PReact] Create a Hello World App with Preact】宝剑锋从磨砺出,梅花香自苦寒来。这篇文章主要讲述[PReact] Create a Hello World App with Preact相关的知识,希望能为你提供帮助。
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;
推荐阅读
- Array.apply(null,{length:20})与new Array(20)的区别
- 使用apply的方法将伪数组转化为数组
- Android底层开发之Linux输入子系统要不要推断系统休眠状态上报键值
- 使用MyBatis-Gererator自动生成Dao.Model.Mapping相关文件
- spring4+srpingmvc+mybatis基本框架(app框架搭建一)
- Android之使用JAVA占位符格式数据(很实用)
- spring——IOC容器BeanFactory和ApplicationContext对比
- Cube 技术解读 | Cube 小程序技术详解
- Flutter 专题89 图解基本 Overlay 悬浮新手引导 #yyds干货盘点#