Skip to content

Commit c419af3

Browse files
committed
Passing Data Through Props
1 parent 7c5da7c commit c419af3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

react_learn/src/main/scala/tutorial/webapp/TutorialApp.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ import org.scalajs.dom
66

77

88
object Square {
9-
val component = ScalaComponent.builder[Unit]("Square")
10-
.renderStatic(
11-
<.button(^.cls := "square")
9+
val component = ScalaComponent.builder[Int]("Square")
10+
.render_P( i =>
11+
<.button(
12+
^.cls := "square",
13+
i
14+
)
1215
)
1316
.build
1417

15-
def apply() = component()
18+
def apply(i: Int) = component(i)
1619
}
1720

1821

1922
object Board {
20-
def renderSquare(i: Int) = Square()
23+
def renderSquare(i: Int) = Square(i)
2124

2225
val component = ScalaComponent.builder[Unit]("Board")
2326
.renderStatic(

0 commit comments

Comments
 (0)