Everything about Slinky -- issues, ideas for features, where it's being used, and more
@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")(
)
)
)
)
}
}
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
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.