You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

19 lines
625 B

package com.example.playscalajsreact.model
import monocle.macros.Lenses
import japgolly.scalajs.react.Reusability
import japgolly.scalajs.react.Reusable
@Lenses
final case class Data(int: Int, str: String)
object Data {
implicit val reusability: Reusability[Data] = Reusability.derive
// Here we wrap the lenses in Reusable.byRef so that React can compare setState/modState functions and know when its
// it's got the same lens as a previous render. This is required to make [Method 1] work with Reusability
object reusableLens {
val int = Reusable.byRef(Data.int)
val str = Reusable.byRef(Data.str)
}
}