Skip to content

Instantly share code, notes, and snippets.

@abdyer
Created April 2, 2019 14:37
Show Gist options
  • Save abdyer/d25f368640d7a72d65f466290260a8a0 to your computer and use it in GitHub Desktop.
Save abdyer/d25f368640d7a72d65f466290260a8a0 to your computer and use it in GitHub Desktop.
Misleading error message when passing a Kotlin inline class as a @prop to a Litho component that also uses @State
package com.example
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.StateValue
import com.facebook.litho.annotations.LayoutSpec
import com.facebook.litho.annotations.OnCreateInitialState
import com.facebook.litho.annotations.OnCreateLayout
import com.facebook.litho.annotations.Prop
import com.facebook.litho.annotations.State
import com.facebook.litho.widget.EmptyComponent
inline class BreaksBuild(val something: String)
@LayoutSpec
object InlineClassIssueComponentSpec {
@OnCreateInitialState
fun createInitialState(c: ComponentContext, text: StateValue<String>, @Prop initialText: String) {
text.set(initialText)
}
@OnCreateLayout
fun onCreateLayout(
c: ComponentContext,
@Prop inlineClass: BreaksBuild,
@State text: String
): Component = EmptyComponent.create(c).build()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment