1

I want to use react-infinite-grid in Kotlin http://ggordan.com/post/react-infinite-grid.html

I have seen the How to import node module in React-Kotlin?

Below code is my reference it:

InfiniteGrid.kt

@file:JsModule("react-infinite-grid")
@file:JsNonModule
package react.infinite.grid

import react.*

external interface InfiniteGridProps: RProps {
    var wrapperHeight: Int
    var entries: Array<*>
}

@JsName("default")
external val InfiniteGrid : RClass<InfiniteGridProps>

main.kt

package index

import kotlinext.js.*
import react.dom.*
import kotlinx.browser.*
import react.infinite.grid.InfiniteGrid

fun main(){
    requireAll(require.context("src", true, js("/\\.css$/")))
    render(document.getElementById("root")) {
        InfiniteGrid{
            attrs.wrapperHeight = 400
            attrs.entries = arrayOf(1, 11, 111, 1111)
        }
    }
}

But, I have error:

Error: Element ref was specified as a string (wrapper) but no owner was set. This could happen for one of the following reasons:

  1. You may be adding a ref to a function component
  2. You may be adding a ref to a component that was not created inside a component's render method
  3. You have multiple copies of React loaded See https://reactjs.org/warnings/refs-must-have-owner.html for more information.

enter image description here

I tried How to import node module in React-Kotlin? two way is not success.

Please Help To Me

Thank You


Update:

I finded is react-infinite-grid cannot support react 16.0.0 or newer.

With Kotlin Wrap No relation.

iHad 169
  • 1,267
  • 1
  • 10
  • 16
  • Your code looks correct (except the entries part). Have you tried rendering with an empty array for entries? – andylamax Sep 28 '20 at 12:18

0 Answers0