Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. package hello.world
  2.  
  3. import slinky.core._
  4. import slinky.core.annotations.react
  5. import slinky.core.facade.ReactElement
  6. import slinky.web.html._
  7.  
  8. import scala.scalajs.js
  9. import scala.scalajs.js.annotation.{JSImport, ScalaJSDefined}
  10.  
  11. @JSImport("resources/App.css", JSImport.Default)
  12. @js.native
  13. object AppCSS extends js.Object
  14.  
  15. @JSImport("resources/logo.svg", JSImport.Default)
  16. @js.native
  17. object ReactLogo extends js.Object
  18.  
  19. @react object RouteAlt extends ExternalComponent {
  20. type Props = typings.reactDashRouterLib.reactDashRouterMod.RouteProps
  21. override val component = typings.reactDashRouterDashDomLib.reactDashRouterDashDomLibComponents.Route[ReactComponentClass[_]]
  22. }
  23.  
  24. @react object App {
  25.  
  26. type Props = Unit
  27.  
  28. import typings.reactLib.ScalableSlinky._
  29. import typings.reactDashRouterDashDomLib.reactDashRouterDashDomLibComponents._
  30. import typings.reactDashRouterLib.reactDashRouterMod.RouteProps
  31. private val css = AppCSS
  32.  
  33. val component = FunctionalComponent[Props] { _ =>
  34.  
  35. def home = div(
  36. h2("Home")
  37. )
  38.  
  39. def about = div(
  40. h2("About")
  41. )
  42.  
  43. def topics = div(
  44. h2("Topics")
  45. )
  46.  
  47. BrowserRouter.noprops(
  48. div(
  49. ul(
  50. li(Link.props(LinkProps(to = "/"))("Home")),
  51. li(Link.props(LinkProps(to = "/about"))("About")),
  52. li(Link.props(LinkProps(to = "/topics"))("Topics"))
  53. ),
  54. hr(),
  55. RouteAlt(RouteProps(exact = true, path = "/", render = _ => home: ReactElement)),
  56. RouteAlt(RouteProps(path = "/about", render = _ => about: ReactElement)),
  57. RouteAlt(RouteProps(path = "/topics", render = _ => topics: ReactElement)),
  58.  
  59. // Original from React Router basic example, to be converted
  60. // <Route exact path="/" component={Home} />
  61. // <Route path="/about" component={About} />
  62. // <Route path="/topics" component={Topics} />
  63. )
  64. )
  65.  
  66. }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement