Monday, July 22, 2019

Thinking in Reagent as a reaction to Thinking in React. A 1:1 transformation from Javascript/React to ClojureScript/Reagent

This article: https://reactjs.org/docs/thinking-in-react.html introduces people to working with React in Javascript. I thought it would be nice to have the same simple application made in Clojurescript with Reagent (which also uses React underneath)

For example

class ProductCategoryRow extends React.Component {
  render() {
    const category = this.props.category;
    return (
     
       
          {category}
       
     
    );
  }

}


In Reagent:

(defn product-category-row-component [category]
  [:tr
   [:th
    {:col-span 2}
    category]])


 I made an interactive presentation and I put it here:

http://www.danbunea.ro/presentations/thinking%20in%20reagent.html




No comments: