Git Product home page Git Product logo

Comments (9)

japgolly avatar japgolly commented on July 24, 2024

Hi Chandra. That's not "the React way". React needs to be created using its virtual dom, not text or using setinnerhtml. I strongly suggest you work within those constraints. If for whatever reason you really really want to do this anyway, try asking in the React mailing list. Good luck.

from scalajs-react.

chandu0101 avatar chandu0101 commented on July 24, 2024

I am reading some blog posts from tumblr API ,they are html , in my app i am trying to render them inside react component. In JSX gotchas i found this line to render html
http://facebook.github.io/react/docs/jsx-gotchas.html

<div dangerouslySetInnerHTML={{__html: 'First &middot; Second'}} />

how can i achieve in scala-js react ?

or is there any other way i can make this workout ..

Thank You
Chandra

from scalajs-react.

japgolly avatar japgolly commented on July 24, 2024

Oh so dangerouslySetInnerHTML is React attribute? I didn't know that. In that can you can create attributes as you need them.

It should be something like this:

val dangerouslySetInnerHTML = "dangerouslySetInnerHTML".attr
...
div(dangerouslySetInnerHTML := "blah blah blah")

from scalajs-react.

chandu0101 avatar chandu0101 commented on July 24, 2024

reacts dangerouslySetInnerHTML attribute accepts jsObject with key __html and value string
in scala i am trying like this

val dangerouslySetInnerHTML = "dangerouslySetInnerHTML".attr
val htmlObj = js.Dynamic.literal("__html"" -> text)
div(dangerouslySetInnerHTML := htmlObj )

but scalatags attribute doesn't accept js.Object :(

from scalajs-react.

japgolly avatar japgolly commented on July 24, 2024

Usage: div(dangerouslySetInnerHtml("<span>"))

from scalajs-react.

chandu0101 avatar chandu0101 commented on July 24, 2024

thank you , is artifact published ?
from ivy cache i removed reactjs

rm -rf com.github.japgolly.*

refreshed sbt ,but still i don't see this attribute ?

from scalajs-react.

japgolly avatar japgolly commented on July 24, 2024

No I haven't published yet. You can run sbt publishLocal to use 0.5.2-SNAPSHOT until 0.5.2 final is published.

from scalajs-react.

joan38 avatar joan38 commented on July 24, 2024

I tried to do:

<.pre(^.dangerouslySetInnerHTML := ???)

But got:

[error] .../LogsPage.scala:31: value dangerouslySetInnerHTML is not a member of object japgolly.scalajs.react.vdom.HtmlAttrAndStyles
[error]             ^.dangerouslySetInnerHTML := ???,

But the thing is that I can see the definition of dangerouslySetInnerHTML.
Do you know what's wrong here?

from scalajs-react.

joan38 avatar joan38 commented on July 24, 2024

Alright it's not dangerouslySetInnerHTML but dangerouslySetInnerHtml

from scalajs-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.