Fork me on GitHub
#reagent
<
2016-05-13
>
michael.heuberger03:05:59

@madvas: it works for you? can you show me the code with the full react lifecycle using i.E. :component-did-mount and renders more material ui components inside? much appreciated, thanks

danbunea08:05:28

Hi, I have a problem with html encoding

danbunea08:05:59

this text: encoded <script>alert(1);<script> is rendered fine by react https://jsfiddle.net/pufhzme5/

rohit08:05:44

@danbunea: this should work. [:h1 "encoded <script>alert(1)<script>”]

rohit08:05:58

you don’t need to escape the text for reagent

danbunea08:05:19

The thing is @rohit that I load the values escaped from the database, in that form: encoded <script>alert(1);<script>

danbunea08:05:26

someone else already escaped it

danbunea08:05:37

I just need to display it on the screen

danbunea08:05:49

but unescaped

rohit08:05:35

@danbunea: you can use the dangerouslySetInnerHTML hack. See this: https://github.com/reagent-project/reagent/issues/14

danbunea08:05:24

I know dangerouslySetInnerHtml

danbunea08:05:36

I used it in react, but it has a lot of disadvantages

danbunea08:05:45

maybe in reagent works better

danbunea08:05:44

I just need to display it on the screen

danbunea08:05:49

not run it as html

danbunea08:05:18

so on the screen it should be: encoded <script>alert(1)<script>

rohit08:05:27

@danbunea: this works for me: [:h1 {:dangerouslySetInnerHTML {:__html "encoded &lt;script&gt;alert(1);&lt;script&gt;"}}]

martinklepsch09:05:43

The (prn 'new new-props) just prints 'new nil

rohit09:05:35

@martinklepsch: just a guess, have you tried, (reagent/children comp)

rohit09:05:10

how are you calling selection-tether

martinklepsch09:05:57

[selection-tether :a :b]

martinklepsch09:05:38

@rohit: children indeed returns what I'd expect

rohit09:05:03

@martinklepsch: to me it makes sense that the props are nil. i don’t see any being passed. children should be [:a :b].

martinklepsch09:05:50

@rohit: I'm confused, how would I pass it correctly?

rohit09:05:50

@martinklepsch: i think props have to be passed when you are calling the selection-tether. also it has to be a map. so something like [selection-tether {…} :a :b].

rohit09:05:01

you may have to restructure things around

rohit09:05:31

also I think you’ll have to store the previous/current data in an atom itself. i’m not sure how to use React to get the previous value

martinklepsch09:05:43

did update gets prevProps & prevState so should be ok without an extra atom

void componentDidUpdate(
  object prevProps, object prevState
)

rohit09:05:53

@martinklepsch: oh nice. i didn’t realise that.

kendall.buchanan15:05:53

Curious if anyone can address this question: I asked it in the #C06DT2YSY channel, and the answer was fairly unsatisfactory: Can components built from Reagent be used in a React JS project?

kendall.buchanan15:05:57

It presupposes other problems like including a compiled Clojurescript library in a JS project, but assuming that’s worked out, could a React component render the results of a Reagent component?