Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 16 18:43
    scala-steward synchronize #583
  • Aug 16 18:43
    scala-steward synchronize #431
  • Aug 16 18:43
    scala-steward synchronize #518
  • Aug 16 18:43
    scala-steward synchronize #546
  • Aug 16 18:42
    scala-steward synchronize #577
  • Aug 16 18:42
    scala-steward synchronize #515
  • Aug 16 18:42
    scala-steward synchronize #570
  • Aug 16 18:42
    scala-steward synchronize #576
  • Aug 15 23:10

    shadaj on main

    Update scala-compiler, scala-li… (compare)

  • Aug 15 23:10
    shadaj closed #578
  • Aug 15 23:09

    shadaj on main

    Update sbt-idea-plugin to 3.15.… (compare)

  • Aug 15 23:09
    shadaj closed #586
  • Aug 15 23:08
    shadaj milestoned #587
  • Aug 15 23:07
    shadaj commented #587
  • Aug 12 14:05
    evbo edited #587
  • Aug 12 14:03
    evbo commented #587
  • Aug 11 18:50
    evbo edited #587
  • Aug 11 18:49
    evbo opened #587
  • Aug 11 03:24
    scala-steward synchronize #586
  • Aug 10 19:06
    scala-steward closed #585
Peter Storm
@peterstorm
Does anyone know what the type parameter to createRef would be, if I want to create a Ref for a MaterialUI TextField?
finnmerlett
@finnmerlett
Does anyone know why slinky decided to do away with the <. prefixing for components? I quite liked it, is there a way to add it in?
Naftoli Gugenheim
@nafg
Anyone using Slinky in scala 3.0.0-M1?
scalajs-react in withDottyCompat mode has lots of issues
mostly because of the overly complex types I think
but also because of a bug
Øyvind Raddum Berg
@oyvindberg
I've just started compiling to slinky on 3.0.0-M1 @nafg , and I'm curious how much works. I guess the lack of macros is going to be quite noticeable :/
Shadaj Laddad
@shadaj
you might be able to get some basic things working right now by disabling hot-reloading (and all the associated Reader/Writer implicits) and using either functional components or the non-`@react` class component style
I think Reader/Writers should be relatively straightforward to port to Scala 3, which would go a long way since that would unlock class components and functional components without @react which isn't too bad an experience
porting the macro annotations will be the most complicated bit, I'm not sure what's the status of those right now
Øyvind Raddum Berg
@oyvindberg
macro annotations are entirely gone from what I understand, hopefully here are some other tools we can use
Naftoli Gugenheim
@nafg
@shadaj even without @react style it required an implicit that summoned a macro
I don't get why Scala.is isn't expressive enough to create class components like in typescript
Peter Storm
@peterstorm
How can I memoize an api call that returns alot of stuff and saves in state? I have a page where I search profiles up, and put the result in state. Then I wanna use react router to go to a specific profile page, to see more detailed information. But when the user the uses the 'back' action, I want the search results to still be there. Is that possible?
Peter Storm
@peterstorm
Oh, and I’m using hooks
Alexis Hernandez
@AlexITC
I'd create a cached service, and you use that instance for the whole app, on how to store it, you can start with a simple var and go from there, I think that scalaz had something for that, it is likely cats does as well.
Peter Storm
@peterstorm
cached service?
Alexis Hernandez
@AlexITC
for example, you can have your normal service that invokes your API, and another implementation depending on such service but handling the cache
Peter Storm
@peterstorm
But I just want react to save the stuff it gets back from my API call? Cant it do that, in context, or something?
Or can you use react router to handle some history maybe?
Alexis Hernandez
@AlexITC
oh, that's done at the component level, the useEffect hook accepts a second argument on when to reload the data, just send "" to load it once
Peter Storm
@peterstorm
Yeah, but as i said above i want it persisted through page “reloads”, does it do that? As i said, i load alot of profiles up with a search, then i can press one of those profiles to get details. If i the press back in the browser, i want the search result persisted.
The useEffect stuff already works, but it doesnt seem to be persisting
Peter Storm
@peterstorm
I might not have explained it well enough 😅
Gabor Juhasz
@gjuhasz86
can you put the state in an outer layer component? that doesn't change between pages
mcallisto
@mcallisto

The useEffect stuff already works, but it doesnt seem to be persisting

@peterstorm If you want to run an effect and clean it up only once (on mount and unmount), you can pass an empty array ([]) as a second argument. Taken from https://reactjs.org/docs/hooks-effect.html#tip-optimizing-performance-by-skipping-effects

Peter Storm
@peterstorm
But thats not exactly what i want, it needs to change with search criterias. And doesnt it get unmounted when you change the page? Or am i misunderstanding something?
mcallisto
@mcallisto
@peterstorm Agreed, in your case you need to store the search results (or the search criteria, if the extraction is fast) somewhere else. Or, depending on the case, you could display the details in a modal within the same component.
Peter Storm
@peterstorm
Does react router have something in the history api or something one could use? It would be fine if it just worked if you pressed back in the browser. But yeah, a modal is a good idea too
mcallisto
@mcallisto
@peterstorm Honestly I have not explored this avenue... I am thinking you could have the search criteria as a prop for the search page and maybe (but maybe not) do something in the history like you arrived with an empty prop but you left with a prop based on your last search. Just thinking aloud, could be a stupid idea.
Anyway it is not viable for storing the results.
Alexis Hernandez
@AlexITC

for example, you can have your normal service that invokes your API, and another implementation depending on such service but handling the cache

@peterstorm this is what I would do, if you use the router, going back doesn't actually refresh the app state, hence, the cache should be live, or you could go hardcore and cache on indexeddb/localstorage, at the end, it is just sharing the same instance on the app's lifecycle

Peter Storm
@peterstorm
But doesnt going away from a page unmount the componenet, and thus all the state? So if I have a list of 10 profiles, press a profile to see a detailed view, then the state of the profile search will be unmounted right? So router shouldn't work there, right?
anyway, ill test it out :D
A different question, sorry, still a noob here :D
I want a prop that takes a type of List[A], but I can't seem to get it to work. Is it possible? It complains that it can't find the A in the Props of the FunctionalComponenet. And I can't give BasicTable a type parameter, that complaines too
```
@react
object BasicTable {

    case class Props[A](tableData: List[A], tableHead: List[String])

    val component = FunctionalComponent[Props[A]] { props =>

        Grid(className := "tableResponsive")(
            table(className := "tableWrapper")(
                thead(className := "tableHead")(
                    tr(className := "tableRow")(

                    )
                )
            )
        )

    }
}
Alexis Hernandez
@AlexITC

But doesnt going away from a page unmount the componenet, and thus all the state? So if I have a list of 10 profiles, press a profile to see a detailed view, then the state of the profile search will be unmounted right? So router shouldn't work there, right?

That's why the same cached states should be propagated to all components depending on such data, it should work, where it wouldn't work is when you reload the page, or a new tab is opened

I haven't been able to get generic types used smoothly and had to recur to inheritance, like here
Peter Storm
@peterstorm
Ah gotcha
Thanks
Gabor Juhasz
@gjuhasz86
Is there a way for functional components to expose methods for their parents? I just finished rewriting all my components to functional, and realized that the next step requires this.
Alexis Hernandez
@AlexITC
that's against react good practices,isn't it? I suggest to came up with a better design
Gabor Juhasz
@gjuhasz86
yeah, it just seems like however I try, encapsulation in general is against react's good practices
Alexis Hernandez
@AlexITC
I think that's part of the unidirectional-flow design, if you post what you are trying to do, or a code sample, I can try to come up with an alternative approach
Gabor Juhasz
@gjuhasz86
Thanks, I'm working on a small scale example, almost finished
Gabor Juhasz
@gjuhasz86
@AlexITC Ok I think I have something
https://scalafiddle.io/sf/A6u6PzL/0
so we have the component Panel that can do some operation on two numbers
This is self contained and works as expected.