[Preact] Create a Hello world App with Preact

Source: Internet
Author: User

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 are solving for us and how are 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 the finally how to render we component into a target element in a Web page.

Index.js

Import {h, render} from ' Preact '; the import App from './components/app '; render (</> , 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> C11/>hello World!!!         </ Div >     );}; Export default App;

[Preact] Create a Hello world App with Preact

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.