Git Product home page Git Product logo

Comments (15)

japgolly avatar japgolly commented on August 27, 2024

Could you paste the error message you're seeing?

from scalajs-react.

dispalt avatar dispalt commented on August 27, 2024

I did some more digging and it's because we wrap the props value { val v: A }, so nothing on the object gets directly exposed to be picked up by the child. I am honestly not sure how this ever worked, it probably didn't.

Each child in an array should have a unique "key" prop. Check the render method of ApplicationTable. See http://fb.me/react-warning-keys for more information.

from scalajs-react.

japgolly avatar japgolly commented on August 27, 2024

Ah, try S.map(f => ApplicationItem(f)).toJsArray and make sure your checkout of this lib includes 5cdd6e0.

from scalajs-react.

dispalt avatar dispalt commented on August 27, 2024

I tried that a couple times, couldn't get it to compile. My understanding is that function is oriented at dom elements vs reactcomponents

I get an error something like this:

Cannot prove that japgolly.scalajs.react.ReactComponentU[fe.models.PApplication,Unit,Unit] =:= japgolly.scalajs.react.vdom.ReactVDom.TypedTag[japgolly.scalajs.react.vdom.ReactOutput].

from scalajs-react.

dispalt avatar dispalt commented on August 27, 2024

If I do something like this (warning ugly) it works:

      S.map { f =>
        val ai = ApplicationItem(f)
        ai.asInstanceOf[js.Dynamic].props.key = f.id
        ai
      }

from scalajs-react.

dispalt avatar dispalt commented on August 27, 2024

A good example of this pattern is here: http://jsfiddle.net/3Vs3Q/light/

from scalajs-react.

japgolly avatar japgolly commented on August 27, 2024

Can you humour me and try .asJsArray instead of .toJsArray?

Separately though, yeah there's no mechanism to set .props.key yet. If it's necessary, your hack will have to do for now and I'll put some friendly support in soon.

from scalajs-react.

dispalt avatar dispalt commented on August 27, 2024

I tried that too, tbh I am having some trouble following the types, I kinda feel like I still don't grasp it all yet.

It seems that there is some special handling for certain props (children, key) that are messing up the model. Would it make sense to just flatten out the props directly on the object? Then that would give the niceties of being able to use JSExport to map directly to fields... Separately I am also running into issues not being able to easily put functions on the spec directly =) Especially if mixins expect a function to be somewhere.

from scalajs-react.

japgolly avatar japgolly commented on August 27, 2024

Yeah, I'm a similar boat 😀 I'm don't even know what JSExport is or does, sounds promising though! I'll have a proper look at that over the weekend (thanks for pointing it out).

Most of what we're talking about here seems to come under the interop umbrella. Scala components talking to Scala components wouldn't use React mixins for example. That whole interacting-with-JS-components space hasn't received much attention yet. It will eventually; I'll probably even start using react-bootstrap myself once I start using this stuff for real.

To get back on topic though, cheers for the demo fiddle. I'll give that a look over the weekend.

from scalajs-react.

japgolly avatar japgolly commented on August 27, 2024

Hey Dan, just pushed a commit for this, you can now give a component a key when you create it and under the covers, it gets put on this.props.key.

from scalajs-react.

dispalt avatar dispalt commented on August 27, 2024

Works perfect thanks!

from scalajs-react.

japgolly avatar japgolly commented on August 27, 2024

Great to hear it

from scalajs-react.

chandu0101 avatar chandu0101 commented on August 27, 2024

Hi ,
i am facing similar issue in 0.5.1

here is my code

  val ProductCategoryRow = ReactComponentB[String]("ProductCateoryRow")
    .render(cateory => tr(key := cateory)(
    th(cateory)
  )) .build

val ProductTable = ReactComponentB[List[Product]]("ProductTable")
    .render(products => {
    val rows = products.map(p => ProductCategoryRow(p.category))
    table(
      thead(
        tr(
          th("Name"),
          th("Price")
        )
      ),
      tbody(
        rows
      )
    )
  }).build

I tired toJSArray and asJSArray , but still key is not added to child component

Each child in an array should have a unique "key" prop. Check the render method of ProductTable. See http://fb.me/react-warning-keys for more information. 

Thanks in advance

from scalajs-react.

japgolly avatar japgolly commented on August 27, 2024

Hi @chandu0101, I believe the info in #27 should solve your problem. Give that try and let me know how it goes.

from scalajs-react.

chandu0101 avatar chandu0101 commented on August 27, 2024

it worked thank you :)

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.