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
Reagent is a ClojureScript wrapper around React. It gives you a way to easily create React components. Reagent has three main features that make it easy to use: using functions to create React components, using Hiccup to generate HTML, and storing state in Reagent Atoms.
As you said, React is just the V in the MVC. So, where do you put your business logic? For small, view-specific business logic, it's ok to put that on the component, as you did. If the business logic is in the component, it's going to be on an event-handler, in the render or any other component method.
To import a function from another file in React: Import the function in file B as import {sum} from './another-file' . Use the imported function in file B .
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"]]])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With