内容简介:ClojureScript optimized for modern React development.Install the latest verion from clojars in your project.A version of "react" and "react-refresh" should be installed automatically; install the corresponding version of your favorite renderer (e.g. "react
Helix
ClojureScript optimized for modern React development.
(ns my-app.core
(:require [helix.core :refer [defnc $]]
[helix.hooks :as hooks]
[helix.dom :as d]
["react-dom" :as rdom]))
;; define components using the `defnc` macro
(defnc greeting
"A component which greets a user."
[{:keys [name]}]
;; use helix.dom to create DOM elements
(d/div "Hello, " (d/strong name) "!"))
(defnc app []
(let [[state set-state] (hooks/use-state {:name "Helix User"})]
(d/div
(d/h1 "Welcome!")
;; create elements out of components
($ greeting {:name (:name state)})
(d/input {:value (:name state)
:on-change #(set-state assoc :name (.. % -target -value))}))))
;; start your app with your favorite React renderer
(rdom/render ($ app) (js/document.getElementById "app"))
Installation
Install the latest verion from clojars in your project.
A version of "react" and "react-refresh" should be installed automatically; install the corresponding version of your favorite renderer (e.g. "react-dom").
shadow-cljs and npm
During development, you'll want to emit ES6 code until polyfills are handled differently . You can do this by passing in a dev compiler configuration:
;; shadow-cljs.edn
{,,,
:builds
{:app
{,,,
:dev {:compiler-options {:output-feature-set :es6}}}}}
Release builds should be able to emit all the way back to ES3.
shadow-cljs and react-native
See React Native .
lein-cljsbuild / figwheel-main / raw CLJS
Use CLJSJS or package react yourself using webpack, ensuring it is provided as the name "react" .
Documentation
View formatted docs at
- Why Helix
- Creating Components
- Creating elements
- Hooks
- Experiments
- Pro-tips
- Frequently Asked Questions
- React Native
Other resources:
License
Copyright © 2020 Will Acton
Distributed under the EPL 2.0
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
我的第一本算法书
[日]石田保辉、[日]宮崎修一 / 张贝 / 人民邮电出版社 / 2018-10 / 69.00元
本书采用大量图片,通过详细的分步讲解,以直观、易懂的方式展现了7个数据结构和26个基础算法的基本原理。第1章介绍了链表、数组、栈等7个数据结构;从第2章到第7章,分别介绍了和排序、查找、图论、安全、聚类等相关的26个基础算法,内容涉及冒泡排序、二分查找、广度优先搜索、哈希函数、迪菲 - 赫尔曼密钥交换、k-means 算法等。 本书没有枯燥的理论和复杂的公式,而是通过大量的步骤图帮助读者加深......一起来看看 《我的第一本算法书》 这本书的介绍吧!