Programming · Games · Life outdoors
Clojure Selmer and ReactJS Data Fetching
Eventually, I’ll get back to this …
Use fetch to communicate state between Clojure Selmer and React JS. For example, …
;;TODO: import useState and useEffect hooks;;See example at https://youtu.be/w7ejDZ8SWv8?t=5293;;TODO: Figure out DELETE and PUT for Selmer
const App = () => {const [someState, setSomeState] = useState("")
useEffect(() => {const fetchTasks = async () => {const res = await fetch('/someendpoint')const data = await res.json()
console.log(data)}}, [])}useEffect in this example fetches the data from a Selmer endpoint that returns JSON. Set state of the properties you wish to change, so React can update its own DOM.