Fork me on GitHub
#reagent
<
2017-02-23
>
souenzzo02:02:59

Hey, how to xhr/fetch?

souenzzo03:02:59

Not realy sure but using it

(defn fetch
  [url options & fs]
  (reduce #(.then %1 %2) (js/fetch url options) fs))

dsapoetra09:02:45

Hi everyone, is there anybody who generated csrf-token in clojurescript? In SPA style

sudodoki09:02:12

do you want to generate it on client side or you are running clojurescript on backend, like on top of node? If first, then wouldn’t it neglect the purpose of csrf if someone else would just copy that code and generate token on their own and use that for malicious purposes?

dsapoetra09:02:29

@sudodoki actually I’m new at SPA style, I use ajax to send data from client (cljs) to backend (pedestal), and I don’t have any idea on how or best practice to do it, Been googling and find : https://gist.github.com/coyotespike/aca29bdeca1eea1e8648 But that doesn’t seem to work on my machine

pesterhazy09:02:36

@dsapoetra no need to ask in every channel

pesterhazy09:02:17

is there a good summary somewhere about CSRF protection and whether it's needed in SPAs?

pesterhazy09:02:17

also, needed for GETs or POSTs only?

pesterhazy09:02:48

I feel like I have a gap in my knowledge there 😉

dsapoetra09:02:53

@pesterhazy POST, need for Login form, and sending some data to get something from DB

dsapoetra10:02:45

@pesterhazy been looking, didn’t find good example/tutorial

pesterhazy10:02:24

thanks anyway 🙂

borkdude11:02:18

I have some issues with React Virtualized components. Would it be appropriate to discuss them here?

borkdude11:02:31

I’ve made Plunkr examples to demonstrate the issues

pesterhazy11:02:55

I think this is a good place

borkdude11:02:12

I’ll just post the first issue then: https://plnkr.co/edit/TrKdNu4FfNsXqERPVnYo?p=preview The issue there is that the loading element doesn’t have the right position/style

borkdude11:02:58

I made JavaScript examples to discuss it with the library maintainer as he doesn’t do ClojureScript, but I think he’s in a different timezone

borkdude11:02:11

The related code is in script.jsx

borkdude12:02:23

I’m closer to a solution. The only thing left to find out is why updateList2 doesn’t work as compared to updateList1: https://plnkr.co/edit/lAddN6eeT8w4PNgTcxNl?p=preview

borkdude16:02:12

I have found the solution, but it wasn’t obvious: https://plnkr.co/edit/lAddN6eeT8w4PNgTcxNl?p=preview

borkdude16:02:25

(see line 58)

joshkh18:02:34

When this is rendered.. [:div {:style {:transform (str "translate(25%, 25%) scale(" 1.2 ")")}}] I only get translate(25%, 25%) and the scale transform is truncated. Is there a way around this?

joshkh18:02:41

I could use a matrix transform but I'd like preserve the transform names

joshkh18:02:56

huh. weird.

joshkh18:02:23

okay thanks, i'll dig deeper!

joshkh19:02:59

next question.. i'm using [reagent "0.6.0" :exclusions [cljsjs/react]] with [cljsjs/react-with-addons "15.4.2-2"] but i'm getting the error js/ReactDOM is missing...

joshkh19:02:20

and i think they're both at their latest versions

pesterhazy19:02:58

a different dependency may rely on another version of react

pesterhazy19:02:41

try boot show -d or lein deps :tree

pesterhazy19:02:55

it may give you a hint

pesterhazy19:02:22

also you could check if window.ReactDOM is available in the chrome dev tools once the page is open

pesterhazy19:02:42

if yes it's probably a order-of-execution problem

joshkh19:02:30

thanks for the advice (again). ReactDOM seems to be missing from the window. rolling back to a previous version of react-with-addons solves the problem for now. 🙂

joshkh19:02:39

well that makes too much sense..

borkdude19:02:30

When I create React elements with r/as-element like (r/as-element [:div @state]) this won’t see new values of state?

pesterhazy19:02:00

can you show the surrounding code?

pesterhazy19:02:08

think about how it works

pesterhazy19:02:55

the fn needs that executes as-element needs to be rerun when the atom changes

borkdude19:02:28

yes, the function call on line 36 doesn’t have any effect

borkdude19:02:22

I guess I need to wrap it in a component

pesterhazy19:02:34

why is the 2nd argument to AutoSizer a fn?

pesterhazy19:02:25

what a weird api - a fn as a child

pesterhazy19:02:09

maybe deref the atom outside the anon fn

pesterhazy19:02:13

bind it in a let

borkdude19:02:16

yes, React Virtualized is full of that

borkdude19:02:37

I’ll just go the component route

pesterhazy19:02:21

basically just return (r/as-element [(fn [] ...)]) ?

pesterhazy19:02:37

that should work as well yeah

pesterhazy19:02:42

they really should have passed the fn as a prop, not a child

borkdude19:02:46

That guy works for FB/React I think

borkdude19:02:10

React JS core team at @facebook

borkdude19:02:17

I hope he knows what he’s doing 🙂

pesterhazy19:02:11

react-virtualized is really high quality

pesterhazy19:02:24

doesn't mean I have to agree with every api decision though 🙂

pesterhazy19:02:44

just because React allows children to be functions doesn't mean it's a good idea

borkdude20:02:56

@pesterhazy Yeah, the [(fn []] thing worked