Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 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
  • Jan 24 22:36
    evbo commented #569
  • Jan 24 20:14
    evbo commented #569
  • Jan 18 20:03
    steinybot opened #619
  • Jan 11 20:15
    evbo commented #330
  • Jan 08 02:10
    scala-steward closed #607
  • Jan 08 02:10
    scala-steward commented #607
  • Jan 08 02:10
    scala-steward opened #618
  • Dec 28 2022 17:35
    scala-steward synchronize #607
  • Dec 28 2022 17:35
    scala-steward synchronize #431
  • Dec 28 2022 17:34
    scala-steward synchronize #612
  • Dec 28 2022 17:34
    scala-steward synchronize #608
  • Dec 28 2022 17:34
    scala-steward synchronize #518
  • Dec 28 2022 17:34
    scala-steward synchronize #605
  • Dec 28 2022 17:34
    scala-steward synchronize #604
  • Dec 28 2022 17:34
    scala-steward synchronize #515
  • Dec 28 2022 17:34
    scala-steward synchronize #590
Peter Storm
@peterstorm
The react annotation
Peter Storm
@peterstorm
Well, i guess that doesnt work. How would i pass a component as props then?
Alexis Hernandez
@AlexITC
that's the way to pass the component, I even have something similar (see), sometimes the macro highlights errors but sbt compiles fine
Peter Storm
@peterstorm
@AlexITC Can you point me to where you use that componenet, and pass another component to it? Can't seem to find that :D
1 reply
I'm probably super confused because it's in a trait, and without the react annotation, but it's a cool project to learn from it seems!
1 reply
Peter Storm
@peterstorm
Ah found it. But whati wanna do is give the actual component as a prop. Like if you defined your own component with @react and a val as a functional component
how do i pass that whole component as a type?
though i guess I could just use vals... hmm, I’ll look at that
Alexis Hernandez
@AlexITC
generally it shouldn't be a problem to propagate a component, it is likely you have a different issue, if you post a snippet, I can take a look
Peter Storm
@peterstorm
Yeah, I'll give it a go again, and else I'll post a snippet. But what would be the type of an object that you created with the @react annotation? If I wanted to pass an object like that around?
Alexis Hernandez
@AlexITC
ReactElement is fine, what matters is the component
Peter Storm
@peterstorm
Ok, now that I have this component that I want to take another component as children
@JSImport("resources/scss/card/style.scss", JSImport.Default)
@js.native
object Style extends js.Object

@react
object Card {

    private val css = Style

    case class Props(title: String, className: String, children: ReactElement)

    val component = FunctionalComponent[Props] { props =>
        Grid(className := s"{props.className} cardWrapper")(
            Grid(className := "cardHeader")(
                div(className := "cardHeaderLeft")(
                    h3(props.title)
                )
            ), props.children
        )
    }
}
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.