首页 > 移动平台 > 详细

[PReact] Create a Hello World App with Preact

时间:2017-06-16 09:54:35      阅读:393      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/Answer1215/p/7023970.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!