Coder Social home page Coder Social logo

Hooks not found inside JSValue about helix HOT 3 CLOSED

lilactown avatar lilactown commented on June 19, 2024
Hooks not found inside JSValue

from helix.

Comments (3)

lilactown avatar lilactown commented on June 19, 2024

I haven't put code to this yet but if I'm understanding the issue right:

When we're in the macroexpansion phase of compiling a CLJS file, our tagged values i.e. #js [(use-state 10)] have already been read and are now an opaque JSValue type, defined here: https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/tagged_literals.cljc#L68

Thus, we need a way of getting the form that is wrapped in this JSValue in order to continue analyzing.

I can think of two ways of doing this:

  1. Special case the analyzer to detect JSValue and access the field (.-val x)
  2. Define a protocol that we extend to JSValue to handle the field access

Using polymorphism for this makes me feel clever, since it would allow outside extension to other reader tags i.e. #hiccup [:div (when true (use-state "hello"))].

I am dubious of the times that this will actually be useful, though.

from helix.

SevereOverfl0w avatar SevereOverfl0w commented on June 19, 2024

I'm not sure if #hiccup would apply here, as that's unable to return a special form without extending the ClojureScript compiler. That means #hiccup has to return a record, list, etc. for the compiler to interpret.

The polymorphic approach was a little annoying because you had to extend it to Object, nil, etc.

from helix.

lilactown avatar lilactown commented on June 19, 2024

Fixed in 27371f0 and 4cfe185

from helix.

Related Issues (20)

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.