reagent

Using React Native MapView in ClojureScript Reagent

只谈情不闲聊 提交于 2021-02-06 13:53:43
问题 I am trying to use MapView from https://github.com/airbnb/react-native-maps using Reagent. It works fine but how could I get local state for MapView when onRegionChange event is fired? Trying to use current/component but it is always nil . (def Expo (js/require "expo")) (def map-view (r/adapt-react-class (.-MapView Expo))) (defn my-map [] (r/create-class {:component-did-mount (fn [this] (println "component mount ")) :reagent-render (fn [] (let [this (r/current-component)] [map-view {:style {

Using React Native MapView in ClojureScript Reagent

*爱你&永不变心* 提交于 2021-02-06 13:50:55
问题 I am trying to use MapView from https://github.com/airbnb/react-native-maps using Reagent. It works fine but how could I get local state for MapView when onRegionChange event is fired? Trying to use current/component but it is always nil . (def Expo (js/require "expo")) (def map-view (r/adapt-react-class (.-MapView Expo))) (defn my-map [] (r/create-class {:component-did-mount (fn [this] (println "component mount ")) :reagent-render (fn [] (let [this (r/current-component)] [map-view {:style {

Using React Native MapView in ClojureScript Reagent

有些话、适合烂在心里 提交于 2021-02-06 13:50:50
问题 I am trying to use MapView from https://github.com/airbnb/react-native-maps using Reagent. It works fine but how could I get local state for MapView when onRegionChange event is fired? Trying to use current/component but it is always nil . (def Expo (js/require "expo")) (def map-view (r/adapt-react-class (.-MapView Expo))) (defn my-map [] (r/create-class {:component-did-mount (fn [this] (println "component mount ")) :reagent-render (fn [] (let [this (r/current-component)] [map-view {:style {

lastCallbackNode is not a function

夙愿已清 提交于 2021-01-29 09:22:13
问题 I've imported the farmer-motion library using shadow-cljs. The framer motion library has the custom react component div.motion. It's used as follows: https://www.framer.com/api/motion/examples/#animation : import { motion } from "framer-motion" export const MyComponent = () => ( <motion.div animate={{ scale: 2 }} transition={{ duration: 0.5 }} /> ) I'm using reagent to render the div.motion component: (ns myapp.foo (:require ;; shadow-cljs import [framer-motion :refer (motion MagicMotion

Why are multi-methods not working as functions for Reagent/Re-frame?

旧时模样 提交于 2021-01-20 23:41:08
问题 In a small app I'm building that uses Reagent and Re-frame I'm using multi-methods to dispatch which page should be shown based on a value in the app state: (defmulti pages :name) (defn main-panel [] (let [current-route (re-frame/subscribe [:current-route])] (fn [] ;... (pages @current-route)))) and then I have methods such as: (defmethod layout/pages :register [_] [register-page]) where the register-page function would generate the actual view: (defn register-page [] (let [registration-form

Tracking mouse in clojurescript / reagent / reagi?

99封情书 提交于 2020-02-03 04:30:34
问题 I'm trying to get to grips with reagent in clojurescript with a simple drawing program. I'm looking for an example of how to access the mouse position in a principled "FRP" inspired style with Reagi. In various reagent examples I can see things that look like this : [:p [:onmousemove (fn (evt) ...)]] to attach a handler to an element of the DOM. And to make a Reagi "behaviour" I want to write something like this : (def mouse-positions (r/behavior ( ... ))) But how do I combine these two so

ClojureScript function prints strings, but will not return hiccup

心不动则不痛 提交于 2019-12-25 01:44:07
问题 I have a ClojureScript component: (defn main-panel [] (def nodes (-> @(re-frame/subscribe [::subs/nodes]))) (defn list-nodes [node] (prn (node :name))) (reagent/create-class {:component-did-mount (fn [] (api-service/get-file-tree)) :reagent-render (fn [] (doseq [node nodes] (if (= (node :depth) 0) (list-nodes node))))})) which prints strings to the console. But when I change the first function to: (defn list-nodes [node] [:<> [:h1 (node :name)]]) I don't get any html that is rendered - no

reagent/adapt-react-class fails with :optimizations :advanced

感情迁移 提交于 2019-12-25 01:36:33
问题 I'm importing a react component (using the :npm-deps support) and wrapping with the adapt-react-class adapter: (:require [reagent.core :as reagent] [react-helmet]) (def meta-tags* (reagent/adapt-react-class (aget react-helmet "default"))) (defn main-panel [] (let [] (fn [] [meta-tags*]))) This works fine for development, but when advanced compiler is on: Uncaught TypeError: Cannot call a class as a function Minimimal repo: https://github.com/fbielejec/npm-deps-demo 回答1: meta-tags* is a class,

reagent component that orders spans by their computed sizes

风格不统一 提交于 2019-12-24 08:01:18
问题 I'm looking for a way to design a reagent component, which lists words sorted by their real(computed) widths, which they would have when rendered in the browser. (not the number of characters). The real width of an html element can be determined by the JavaScript method offsetWidth . However, it looks that in order to get a result, the element must be appended somewhere in the DOM. So this could be imperatively solved by creating a temporary, invisible container element appending some spans

Which changes to clojurescript atoms cause reagent components to re-render?

和自甴很熟 提交于 2019-12-24 05:46:14
问题 Consider the following reagent component. It uses a ref function, which updates a local state atom, based on the real size of a span element. This is done in order to re-render the component displaying its own size (defn show-my-size-comp [] (let [size (r/atom nil)] (fn [] (.log js/console "log!") [:div [:span {:ref (fn [el] (when el (reset! size (get-real-size el))))} "Hello, my size is:" ] [:span (prn-str @size)]]))) If the implementation of get-real-size returns a vector, the log message