Coder Social home page Coder Social logo

fast-refresh with react-native about helix HOT 6 CLOSED

lilactown avatar lilactown commented on July 18, 2024
fast-refresh with react-native

from helix.

Comments (6)

aiba avatar aiba commented on July 18, 2024

Per #29 I got this working with the latest helix code.

I'd suggest putting a note in the documentation that helix works with react-native, and that you need to tell the react-native dev simulator to "Disable Fast Refresh" when you do your own helix fast-refresh hooking.

from helix.

lilactown avatar lilactown commented on July 18, 2024

I haven’t used React Native since they introduced the Fast Refresh feature. Would you be willing to open a PR with instructions on how to get started with it? I bet others would appreciate it!

from helix.

aiba avatar aiba commented on July 18, 2024

Yes, I'd be happy to.

Hooking into react's own fast-refresh feature is a huge selling point for anyone working with react-native. Especially when using navigation libraries like react-navigation, which don't quite work with the other clojurescript ways of doing live code reloading. With helix, however, I have confirmed react-navigation works perfectly.

I will open a PR with instructions and examples, based on what I've learned.

from helix.

lilactown avatar lilactown commented on July 18, 2024

Great!

Please be aware, there's currently a couple WIP things about the React Refresh integration:

  • Custom hooks are not invalidated correctly all the time; there are plans to leverage defhook to provide this functionality
  • When testing with web, transitive namespaces do not trigger a refresh. Example:
(ns app.a
  (:require
   [app.b]
   [helix.core :refer [defnc]])

(defnc app
  []
  (app.b/greet "Refresh"))
(ns app.b
  (:require 
   [app.c]))

(defn greet
  [name]
  (str app.c/greeting ", " name "!"))
(ns app.c)

(def greeting "Bonjour")

Editing app.c/greeting to "Hello" will not trigger app.a/app to refresh.

I'm not sure if this behavior is different in React Native; it is dependent on whether app.a gets reloaded when transitive namespaces are edited. shadow-cljs on the web currently only reloads namespaces that directly depend on the edited namespace.

from helix.

aiba avatar aiba commented on July 18, 2024

shadow-cljs on the web currently only reloads namespaces that directly depend on the edited namespace.

Funny you should mention this. For this exact scenario, shadow-cljs now has a {:reload-strategy :full} option. See thheller/shadow-cljs#349 (comment)

from helix.

lilactown avatar lilactown commented on July 18, 2024

Oh! That's actually fantastic; it had been on my mind to try and create PR for shadow for that and haven't had nearly the time to get spun up on it.

Noting that config option in the Fast Refresh docs would also be a good addition.

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.