Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 02 20:50
    scala-steward synchronize #622
  • Feb 02 20:50
    scala-steward synchronize #618
  • Feb 02 20:50
    scala-steward synchronize #431
  • Feb 02 20:49
    scala-steward synchronize #612
  • Feb 02 20:49
    scala-steward synchronize #608
  • Feb 02 20:49
    scala-steward synchronize #518
  • Feb 02 20:49
    scala-steward synchronize #605
  • Feb 02 20:49
    scala-steward synchronize #604
  • Feb 02 20:48
    scala-steward synchronize #621
  • Feb 02 20:48
    scala-steward synchronize #515
  • Feb 02 20:48
    scala-steward synchronize #590
  • Feb 02 20:48
    scala-steward synchronize #620
  • Feb 02 17:52

    shadaj on main

    Add "React / Binding.scala / ht… (compare)

  • Feb 02 17:52
    shadaj closed #623
  • Feb 01 20:31
    Atry edited #623
  • Feb 01 20:29
    Atry opened #623
  • Jan 28 00:34
    scala-steward opened #622
  • Jan 28 00:34
    scala-steward opened #621
  • Jan 28 00:34
    scala-steward opened #620
  • Jan 25 22:50
    evbo commented #569
Peter Storm
@peterstorm
How do I pass an actual React Component to that then? @AlexITC
Gabor Juhasz
@gjuhasz86

I think in the caller component's render method you can do something like this:

def render = Card(title = "card", className = "mycard")(div("foo"))

(div("foo") being the ReactElement passed as children)

I think if you name a property children, it's special, and becomes a second parameter list
Peter Storm
@peterstorm
I got it to work with this weird syntax that I got from Alex :D
ProfileSearch.component(ProfileSearch.Props(props.search))
But I'll try your way too
Alexis Hernandez
@AlexITC
Such weird syntax is what the macro ends up writing, I use that to avoid the highlighting errors from intellij
Gabor Juhasz
@gjuhasz86
I don't get highlighting errors (after struggling with it for a good while). I assume you are missing the Slinky extension?
1 reply
I'm on Slinky 0.6.6, but the extension didn't work for that version, and I found the previous version in my ivy cache.
~/.ivy2/cache/me.shadaj/slinky-core-ijext_2.12/jars/slinky-core-ijext_2.12-0.6.5.jar
It worked with that (not quite immediately, but eventually)
Peter Storm
@peterstorm
Is it possible to use font-awesome from npm with slinky?
Alexis Hernandez
@AlexITC
I think that material-ui already integrates that one, see https://github.com/ScalablyTyped/SlinkyDemos
Peter Storm
@peterstorm
Hmmm, where exactly? @AlexITC
But your repo has saved me, its much more enjoyable writing Slinky now that i know how to pass components to compoments :)
1 reply
Alexis Hernandez
@AlexITC
4 replies
Gabor Juhasz
@gjuhasz86
image.png
@AlexITC works for me
and yes the extension fixed it
not sure if this is relevant, but IntelliJ 2020.2.3 CE
Alexis Hernandez
@AlexITC
that's great to know, I'll try it later, thanks
Gabor Juhasz
@gjuhasz86
np
ah almost forgot, after adding the extension, I had to restart IntelliJ
Peter Storm
@peterstorm
So I thought I had figured out a clever way to build up my Sidebar links, using a case class called SideBarLinks, and in there I wanted either pngs as js.Objects or MaterialIcons as SVGElements. But when I tried it with MaterialIcons I keep getting Uncaught java.lang.IllegalStateException: This component has already been built into a ReactElement, and cannot be reused when I open and close my menu, which is weird, right?
I might have explained it poorly, but maybe someone has tried something similar, and can help me see whats going on
It loads fine when the page is not in "mobile view", when the menu is just visible all the time
Øyvind Raddum Berg
@oyvindberg
don't store it in a val
Peter Storm
@peterstorm
Ah, what do I store it as then?
Øyvind Raddum Berg
@oyvindberg
a def
Peter Storm
@peterstorm
Thank you so much, that worked!
Øyvind Raddum Berg
@oyvindberg
no problem. I'm not really sure where that limitation comes from, I can't really see what can go so wrong
Pascal Mengelt
@pme123
After lots of problems with Intellij I tried with VSCode and it worked great with Metals.
Gabor Juhasz
@gjuhasz86
how do people deal with asynchrony? For example I have a component with a boolean state shouldAggregate, and another one that holds a key based on which it loads a list of items from the server. Now, on a user click I want to change the key as well as the shouldAggregate, but the aggregation takes into effect immediately (this happens on the client) while loading the list takes time, so after the click I can see the current list aggregated before the new items arrive.
Anyone had to deal with similar situation and have a good solution?
Alexis Hernandez
@AlexITC
I created a component for that, so that the component depending on the async result renders only when the result is ready
Gabor Juhasz
@gjuhasz86
Thank you, checking
so when it's loading it shows a progress indicator, right?
Gabor Juhasz
@gjuhasz86
I'm wondering if it can be rewritten to show the previous state while it's loading. I guess it's only possible if I pipe the shouldAggregate through this component's state as well
Alexis Hernandez
@AlexITC
you can certainly override the in progress behaviour to display something else
Gabor Juhasz
@gjuhasz86
yeah. I'll have to hold the previous state somewhere, though. But this gave me an idea.
roughly:
DisplayPrefs { shouldAggregate0 =>
  ItemFetcher(onComplete = gate.release()) { items =>
    Gate(state = shouldAggregate0) { shouldAggregate => 
      (if(shouldAggregate) aggregate(items) else items)
        .map{ item => div(onClick = {fetcher.load(item))(item.name); dispPrefs.setAggregate(true)} }
    }.withRef(gate)
  }.withRef(fetcher)
}.withRef(dispPrefs)
Gabor Juhasz
@gjuhasz86
only hiccup I guess is that whenever I need multiple states to be piped through the same Gate I'll have to change the type of the Gate too.
I like your workaround for implementing generic components. (I still wish it was supported out of the box, though)
Alexis Hernandez
@AlexITC
this could do the trick
Gabor Juhasz
@gjuhasz86
That looks promising. thank you! I'll have take a deeper look into hooks. I haven't used them yet
nkgm
@nkgm
Any working examples of slinky.reactrouter? I'm trying Route("/", DashboardPage, exact = true) but I get required: slinky.core.ReactComponentClass[_].
Alexis Hernandez
@AlexITC
I have one and there is another one
nkgm
@nkgm
Thanks so much @AlexITC, just what I was looking for. I don't see any mention of useParams hook anywhere on slinky.reactrouter. Is there a way of adding it to the existing facade (other than forking slinky itself)?
Alexis Hernandez
@AlexITC
very likely, isn't it being generated already by scalablytyped?
nkgm
@nkgm
I'm looking into that, but would I have to remove slinky.reactrouter completely and use the facade generated by scalablytyped in its place?
Alexis Hernandez
@AlexITC
I don't know about slinky.reactrouter but scalablytyped generated facades generally work quite well
Øyvind Raddum Berg
@oyvindberg
there's a pretty high chance you can mix and match the two approaches, since they both use the same javascript in the end
whether you want to keep two approaches is obviously another question :)