Everything about Slinky -- issues, ideas for features, where it's being used, and more
Panel
that can do some operation on two numbers
Panel
s and define linkage between them (dynamically), so that the one panel's output is piped to the other panel's first input.
package connect.ui.components.auth
import slinky.core._
import slinky.core.annotations.react
import slinky.web.html._
import org.scalajs.dom
import slinky.core.facade.{Fragment, ReactElement}
import slinky.web.ReactDOM
import slinky.core.facade.React
import slinky.core.facade.Hooks._
import typings.reactRouterDom.{ components => router}
import scala.scalajs.js
import connect.ui.domain.authentication.Auth
import org.scalablytyped.std.global.console
@react
object AuthContextProvider {
val authContext = React.createContext[Auth](Auth(false, "", "", 0, () => ()))
case class Props(test: String, children: ReactElement*)
val component = FunctionalComponent[Props] { props =>
val (isAuthenticated, setIsAuthenticated) = useState(false)
def loginHandler(): Unit = {
console.log("loginHandler called")
setIsAuthenticated(true)
router.Redirect(to = "/")
}
authContext.Provider(value = Auth(isAuthenticated, "", "", 0, loginHandler _))(
props.children
)
}
}
useContext(AuthContextProvider.authContext)
in a different component
AuthContextProvider.authContext.Consumer( context => ...)
it works
@react
working, since the remaining macros are mostly just for typeclass derivation.