reagent

re-frame: nvd3 graph doesn't respond to when its component's subscriptions are updated

▼魔方 西西 提交于 2019-12-22 11:28:08
问题 I'm using the re-frame cljs framework which uses reagent as its view library. I have an nvd3 graph component that I want to be updated when its subscriptions update. Unfortunately, the graph never updates itself after the initial call to :component-did-mount . :component-will-update is never called again after the intial render. I want the graph to update itself as the subscription notifies the components of the dat it's listening to being changed. Here's the graph-container component: (defn

Enumerate namespaces and dynamically load them in ClojureScript

感情迁移 提交于 2019-12-21 18:02:42
问题 This may actually be a bit of an XY-problem, so I'll try to explain what the goal is first. I'm building a ClojureScript application which is composed of a set of Reagent components. It provides a user interface where you can dynamically add or remove UI elements. These UI elements (components) have a certain type. For example a Markdown component is-a Text component. Whenever the user is presented with the option to add Text we list all the components that match the type+descendants (in this

How To Detect “Enter” Keypress in Reagent?

五迷三道 提交于 2019-12-12 08:24:51
问题 Given the following code: [:input {:type "text" :value (:text @app-state) :on-change (fn [e] (if (= 31 (.-keyCode e)) (println "ENTER") (println "NOT ENTER")))}] How to change the if condition so that enter keypresses can be distinguished from normal keys? All properties in e except target seem to be null. 回答1: that's how to fix it: you should listen to :on-key-press (rather than :on-change ), because "enter" doesn't trigger :on-change event (it obviously doesn't change the text) key code for

Clojurescript/Reagent Unit testing component - simulate onChange

冷暖自知 提交于 2019-12-12 01:39:23
问题 For a component where I have a textbox, I need to be able to change the text in it from the test: (defn choose-city-component [] (let [inner-state (r/atom {:text ""})] (fn [] [:div [:input#txt_city { :type "text" :value (@inner-state :text) :on-change #(swap! inner-state assoc :text (-> % .-target .-value))... In the test I render it on the screen: (deftest choose-city-component-test-out ;;GIVEN render component in test (let [comp (r/render-component [w/choose-city-component] (. js/document

:on-click renders as text

孤人 提交于 2019-12-11 15:38:34
问题 My ClojureScript function: (defn node-function [node] [:<> [:div (node :name) {:on-click #(prn "hi")}]]) renders as html text in the dom: My Documents{:on-click #object[Function]} My code looks exactly the same as :on-click examples I've found online. Why does the compiler think this is text and not a function? Thanks. 回答1: I'm not sure how the rest of your project is structured, but it looks like the property map and inner html of the div you're trying to render are transposed. The reason

How to use common dependencies in different clojurescript projects?

喜夏-厌秋 提交于 2019-12-11 02:35:13
问题 I wrote a clojurescript project. It is a reagent component. Now i want to use this component in other clojurescript project. That is what i do: I compiled my cljs project and then i put a result compiled file to js folder in other project. Further i require that file from index.html. At the end i invoke my component from cljs file (.slider-view (.-views js/swipe) (clj->js [[:p "1"] [:p "2"] [:p "3"]])) and it works. But i have a question. My project and project where i connect my component

How to use a ReactJS Component with Clojurescipt/Reagent

╄→гoц情女王★ 提交于 2019-12-09 15:59:15
问题 Is it possible to wrap ReactJS components for use with Reagent in Clojurescript? I have read that it is. Can someone provide me with a basic example? Thanks 回答1: Here is my solution for it (I am going to use a React-Bootstrap Panel Component): 1) Include react-bootstrap.min.js in your html. 2) Here is a sample usage of the Panel component: (def PanelComp (. js/ReactBootstrap -Panel)) (defn page [] [:div [:div [PanelComp {:header "Panel heading without title"} "Panel content"]]]) 来源: https:/

Enumerate namespaces and dynamically load them in ClojureScript

烈酒焚心 提交于 2019-12-04 10:59:26
This may actually be a bit of an XY-problem , so I'll try to explain what the goal is first. I'm building a ClojureScript application which is composed of a set of Reagent components. It provides a user interface where you can dynamically add or remove UI elements. These UI elements (components) have a certain type. For example a Markdown component is-a Text component. Whenever the user is presented with the option to add Text we list all the components that match the type+ descendants (in this case Markdown, there could be others). The way I've coded it up is as follows. Each component is in

How to dynamically change page title and description in ClojureScript / Reagent

牧云@^-^@ 提交于 2019-12-03 20:57:36
Is there a simple way to change document title and description (or other [:html [:head [:meta tags) from ClojureScript Reagent application? For example on every bidi route match change the title and description to match the new page content. Preferably this should work without using js/window so that the same code can be used in a browser as well as in server isomorphic pre-rendering (which I need for SEO). In the JavaScript/React world there are react-document-meta and react-side-effect which can probably be converted to Reagent components. But this way of handling side effects seems like a

use predefine react component from reagent?

混江龙づ霸主 提交于 2019-12-03 09:34:34
问题 I have some external UI with abstraction of react components and I want to reuse them from reagent, is there any way to directly render predefined react component just by passing data from clojurescript. I am a clojurescript beginner. 回答1: Let's try! We can start by writing the component in a js file. var CommentBox = React.createClass({displayName: 'CommentBox', render: function() { return ( React.createElement('div', {className: "commentBox"}, this.props.comment ) ); } }); Then we can call