Fabric Component Example fails on yarn android (missing type argument for delegate class) #236
-
Hey folks, I've been walking through the Fabric native components documentation and hit an error when running the Android side of things (using Kotlin). As far as I can tell, I have pretty much just copy/pasted the example code line-for-line. The error I get when I run e: file:///Users/tylerwilliams/react-native-components-but-worse/example/node_modules/RTNCenteredText/android/src/main/java/com/rtncenteredtext/CenteredTextManager.kt:14:55 2 type arguments expected for class RTNCenteredTextManagerDelegate<T : View!, U : BaseViewManagerInterface<T!>!> where U : RTNCenteredTextManagerInterface<T!>!
FAILURE: Build failed with an exception. Here is my file which looks pretty identical: package com.rtncenteredtext
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.SimpleViewManager
import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.uimanager.ViewManagerDelegate
import com.facebook.react.uimanager.annotations.ReactProp
import com.facebook.react.viewmanagers.RTNCenteredTextManagerInterface
import com.facebook.react.viewmanagers.RTNCenteredTextManagerDelegate
@ReactModule(name = CenteredTextManager.NAME)
class CenteredTextManager(context: ReactApplicationContext) : SimpleViewManager<CenteredText>(), RTNCenteredTextManagerInterface<CenteredText> {
private val delegate: RTNCenteredTextManagerDelegate<CenteredText> = RTNCenteredTextManagerDelegate(this)
override fun getDelegate(): ViewManagerDelegate<CenteredText> = delegate
override fun getName(): String = NAME
override fun createViewInstance(context: ThemedReactContext): CenteredText = CenteredText(context)
@ReactProp(name = "text")
override fun setText(view: CenteredText, text: String?) {
view.text = text
}
companion object {
const val NAME = "RTNCenteredText"
}
} When I try to add different type arguments like this: private val delegate: RTNCenteredTextManagerDelegate<CenteredText, RTNCenteredTextManagerInterface<CenteredText>> = RTNCenteredTextManagerDelegate(this) I end up with errors like this: e: file:///Users/tylerwilliams/react-native-components-but-worse/example/node_modules/RTNCenteredText/android/src/main/java/com/rtncenteredtext/CenteredTextManager.kt:15:121 Type mismatch: inferred type is RTNCenteredTextManagerInterface<CenteredText> but BaseViewManagerInterface<TypeVariable(T)!>! was expected
e: file:///Users/tylerwilliams/react-native-components-but-worse/example/node_modules/RTNCenteredText/android/src/main/java/com/rtncenteredtext/CenteredTextManager.kt:15:121 Type mismatch: inferred type is RTNCenteredTextManagerInterface<CenteredText> but BaseViewManagerInterface<CenteredText!>! was expected If I flip over to BaseViewManagerInterface<CenteredText!>, I get the opposite error instead. Is it likely that I missed a step, or did something change on the codegen side and not get updated in the documentation? I know these docs are early and unstable, so I figured I'd ask around/maybe flag some kind of drift. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Just FYI, we're updating that guide and we're going to merge it updated on the website between today/tomorrow. |
Beta Was this translation helpful? Give feedback.
Just FYI, we're updating that guide and we're going to merge it updated on the website between today/tomorrow.