[PReact] Create a Hello World App with Preact
Posted Answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[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;
以上是关于[PReact] Create a Hello World App with Preact的主要内容,如果未能解决你的问题,请参考以下文章
如何在 React / Preact(又名 <If> 组件)中传递条件子级
jira插件开发——Create a Confluence 'Hello World' macro