Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 10:57
  • Jan 30 22:22
    bitpirate starred japgolly/scalajs-react
  • Jan 30 08:11

    japgolly on master

    Update docs for changes in 1.4.0 (compare)

  • Jan 28 08:08
    booleguo starred japgolly/scalajs-react
  • Jan 28 04:09

    japgolly on v1.4.0

    (compare)

  • Jan 28 04:05

    japgolly on master

    Towards v1.4.1 (compare)

  • Jan 28 04:04

    japgolly on master

    Prepare for v1.4.0 Upgrade React to 16.6.3 React.lazy and 85 more (compare)

  • Jan 28 04:04
    japgolly closed #521
  • Jan 28 04:04
    japgolly opened #521
  • Jan 28 04:03

    japgolly on v1.4.x

    Add note about Reusability/Reus… doc formatting Prepare to release v1.4.0 (compare)

  • Jan 28 04:02
    wiitht starred japgolly/scalajs-react
  • Jan 28 03:18

    japgolly on v1.4.x

    Test AsyncCallback.init Update Travis CI caching (compare)

  • Jan 28 03:02

    japgolly on v1.4.x

    Update Travis CI cache dirs Revise changelog (compare)

  • Jan 28 03:00
    japgolly labeled #520
  • Jan 28 03:00
    japgolly labeled #519
  • Jan 27 17:36
  • Jan 26 06:49
    japgolly commented #520
  • Jan 26 05:55
    japgolly commented #519
  • Jan 26 02:35
    cquiroz opened #520
jhegedus42
@jhegedus42
can e be something else ? and then that something else can contain the router ?
so , does it make sense to put the router "not directly" into the e but rather into a wrapper component ?
and then put that wrapper component into e ?
so that the wrapper component can handle the login ?
or, for example, when the app starts, then it has component a mounted into e
and once the login completed successfully (which is handled by component a) then component a mounts the router into e ?
jhegedus42
@jhegedus42
or should I put an onComponentMounted somewhere which checks if the user is logged in, and if not, then it redirects the route to the login page ?
jhegedus42
@jhegedus42
ok, here is a possible solution :

 def wrapperConstructor(routerCtl: RouterCtl[MainPage]) =
    ScalaComponent
      .builder[CacheAndPropsAndRouterCtrl[Props]]("Wrapper")
      .renderBackend[WrapperBackend]
      .componentWillMount(
        $ => {
          val r1: Callback = Callback {
            ReRenderer.setTriggerer(ReRenderTriggerer(() => {
              $.setState(Unit).runNow()
            }))
          }

          val r2: Callback = routerCtl.set(LoginPage)

          val r3: Callback =
            if (LoginPageComp.isUserLoggedIn.yesOrNo) {
              r1
            } else r2

          r3

        }
      )
      .build
routerCtl.set(LoginPage) should "re route" the app to the login page ...
as far as I imagine
am I using it wrong ?
how can I use the routerCtl to send the app to an other page ?
is this the correct way ?
Yilin Wei
@yilinwei
What version of the library should I be using for scala 2.13? Struggling to find a combo of ScalaJS and this library that it's happy with.
Yilin Wei
@yilinwei
Never mind; the issue was the bundler plugin was causing the correct scalajs compiler to get evicted and the library hasn't been compiled against 1.0.0 yet.
Abdhesh Kumar
@abdheshkumar
It is possible to render a component when the user presses a browser back button? For example, I am calling API in componentDidMount for getting data and I also have filters like Amazon. When the user changes filters, I am appending selected filters into URL. When the user moves on another page and then press the back button. I want to extract filters from URL and pass them into API which I called in componentDidMount.
Raúl Piaggio
@rpiaggio
Hi @japgolly, how far, if any, have you gotten in defining cats-effect instances for CallbackTo ?
Roberto Leibman
@rleibman
Hi! I'd like to have one "global" piece of data that gets passed to all the pages by the router (basically the user preferences) and I don't want every page to have to query the server for it. I can't figure out quite how to do this... I have a component inside my router class that retrieves the data from the server and stores it in a State class. But from there, I don't know quite how to get at it to pass it to the pages (in their constructors, I imagine) which are called within the route.
Øyvind Raddum Berg
@oyvindberg
that sounds like something you can use react context for
Roberto Leibman
@rleibman
Tell me more!
Øyvind Raddum Berg
@oyvindberg
Roberto Leibman
@rleibman
Yeah, it does sound like it's meant for that.
And it seems like it's already part of scalajs-react, cool.
Are there any examples you know of?
Øyvind Raddum Berg
@oyvindberg
no idea
Roberto Leibman
@rleibman
Awesome news, my project all compiles and actually runs! There's a few items I need to fix here and there, but I'm really happy with the whole thing working!
Øyvind Raddum Berg
@oyvindberg
That's really great @rleibman . Not bad when replacing all the code running underneath your app :)
Roberto Leibman
@rleibman

@japgolly hey... we're encountering an issue in wrapping a js component, it uses render props, so it's children are not Vdoms, but functions. They use them something like this:

<MyComponent>
{({someprops}) => (
<div>hello world</div>
)}
</MyComponent>

I don't know what the solution is, but maybe In trying to wrap the component, I have a choice of None or Varargs children... maybe add a third option Function[PropType]

In which case I would pass to the constructor PropType => CallbackTo[Seq[ChildArg]]
or something like that.
I am able to workaround the whole thing by passing a specific children parameter in the first bunch that matches the type I need and setting it in the dynamic object manually, but it would be nice scalajs react supported it out of the box.
Roberto Leibman
@rleibman
Question: with the router, how would I pass a query param to one of my pages? e.g. "http://localhost/#mypage?name=yoyo"
Roberto Leibman
@rleibman
Anwser: (to myself) this issue actually resolves my question: japgolly/scalajs-react#372
Roberto Leibman
@rleibman
I tried running sbt test on the project (the lastest code in master) and I get the following error:
internal/modules/cjs/loader.js:775
    throw err;
    ^

Error: Cannot find module 'jsdom'
Require stack:
- /Volumes/Personal/projects/scalajs-react/[stdin]
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
    at Function.Module._load (internal/modules/cjs/loader.js:677:27)
    at Module.require (internal/modules/cjs/loader.js:830:19)
    at require (internal/modules/cjs/helpers.js:68:18)
    at [stdin]:111:15
    at [stdin]:196:3
    at Script.runInThisContext (vm.js:126:20)
    at Object.runInThisContext (vm.js:316:38)
    at Object.<anonymous> ([stdin]-wrapper:9:26)
    at Module._compile (internal/modules/cjs/loader.js:936:30) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Volumes/Personal/projects/scalajs-react/[stdin]' ]
}
[error] org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: Node.js with JSDOM exited with code 1
[error]     at org.scalajs.jsenv.ExternalJSEnv$AbstractExtRunner.waitForVM(ExternalJSEnv.scala:133)
[error]     at org.scalajs.jsenv.ExternalJSEnv$AsyncExtRunner$$anon$2.$anonfun$run$2(ExternalJSEnv.scala:198)
[error]     at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]     at scala.util.Try$.apply(Try.scala:213)
[error]     at org.scalajs.jsenv.ExternalJSEnv$AsyncExtRunner$$anon$2.run(ExternalJSEnv.scala:198)
[error] (test / Test / loadedTestFrameworks) org.scalajs.jsenv.ExternalJSEnv$NonZeroExitException: Node.js with JSDOM exited with code 1
[error] Total time: 6 s, completed Nov 15, 2019, 11:42:47 AM
Raúl Piaggio
@rpiaggio
Roberto Leibman
@rleibman
Cool, thanks.
Roberto Leibman
@rleibman
@japgolly David, have you thought about changing the definition of Callback to use ZIO? I think it would be a good match, and you may be able to do it unobtrusively without breaking much.
Raúl Piaggio
@rpiaggio
@rleibman Please see japgolly/scalajs-react#503, it's not about ZIO specifically, but I think it applies
Roberto Leibman
@rleibman
Yeah, ok, I get it. So maybe adding an extra for ZIO similar to the ones for cats and scalaz.
Raúl Piaggio
@rpiaggio
well, at the moment we are starting an effort to make it generic, see japgolly/scalajs-react#590
Łukasz Drygała
@ldrygala

Hi, i’m writing facade for react component which props use

propTypes: {
    inputA: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
    inputB: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
    type: React.PropTypes.oneOf(['chars', 'words', 'sentences', 'json'])
  }

Does anyone know how to model React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]) this in scalajs ?

Abdhesh Kumar
@abdheshkumar

Hi, i’m writing facade for react component which props use

propTypes: {
    inputA: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
    inputB: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]),
    type: React.PropTypes.oneOf(['chars', 'words', 'sentences', 'json'])
  }

Does anyone know how to model React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.object]) this in scalajs ?

I think you don't need to write facade for PropType as you will use case class for react props which are already typed.

Paul Cleary
@pauljamescleary
newb to ScalaJS and scalajs-react; is there an easy way to spit out an already rendered HTML string?
Matt Hughes
@matthughes
@pauljamescleary I believe you want dangerouslySetInnerHTML
Matt Hughes
@matthughes
in sjs-react terms that’s an attribute: <.div(^. dangerouslySetInnerHTML := “<span>hi there </span>”)
Paul Cleary
@pauljamescleary
I saw that but it sounded......
Dangerous
Thanks!