Giter Site home page Giter Site logo

zhuangxm / helix Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lilactown/helix

0.0 0.0 0.0 857 KB

A simple, easy to use library for React development in ClojureScript.

License: Eclipse Public License 2.0

Clojure 97.50% HTML 1.49% CSS 0.03% JavaScript 0.98%

helix's Introduction

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

Clojars Project

Install the latest version 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 cljdoc badge

Other resources:

License

Copyright © 2020 Will Acton

Distributed under the EPL 2.0

helix's People

Contributors

lilactown avatar lucywang000 avatar alidcast avatar aiba avatar darwin avatar stanislas avatar severeoverfl0w avatar tomconnors avatar wilkerlucio avatar danieroux avatar jimmyhmiller avatar tomekw avatar zackteo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.