Roger Kreienbühl
03/09/2020, 9:40 AM@file:JsModule("react-grid-layout")
@file:JsNonModule
import kotlinext.js.Object
import react.RClass
import react.RProps
@JsName("default")
external val ReactGridLayout: RClass<GridLayoutProps>
external interface GridLayoutProps: RProps {
var autoSize: Boolean
var cols: Int
var calssName: String
var style: Object
var draggableHandle: String
var draggableCancel: String
var containerPadding: Any
var rowHeight: Int
var maxRows: Int
var layout: Array<IntArray>
var margin: Array<Int>
var isDraggable: Boolean
var isResizable: Boolean
var isDroppable: Boolean
var useCSSTransforms: Boolean
var transformScale: Int
var verticalCompact: Boolean
var compactType: String?
var preventCollision: Boolean
var droppingItem: Object
var onLayoutChange: Any
var onDragStart: Any
var onDrag: Any
var onDragStop: Any
var onResizeStart: Any
var onResize: Any
var onResizeStop: Any
var onDrop: Any
}
When I now try to use this, I only get errors.
What am I doing wrong?Grantas33
03/09/2020, 4:11 PMRoger Kreienbühl
03/09/2020, 4:14 PMWarning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `App`.
in App
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `App`.
The above error occurred in the <App> component:
in App
Consider adding an error boundary to your tree to customize error handling behavior.
Visit <https://fb.me/react-error-boundaries> to learn more about error boundaries.
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `App`.
Grantas33
03/09/2020, 4:15 PMval reactGridLayout = require("react-grid-layout")
and console.log it to see what it printsRoger Kreienbühl
03/09/2020, 4:18 PMrequire("react-grid-layout")
I get a Type mismatch
Required Boolean, Found StringGrantas33
03/09/2020, 4:20 PMGrantas33
03/09/2020, 4:21 PMRoger Kreienbühl
03/09/2020, 4:21 PMimport RGL, { WidthProvider } from "react-grid-layout";
const ReactGridLayout = WidthProvider(RGL);
How can I achieve this in Kotlin?Grantas33
03/09/2020, 4:22 PMval reactGridLayout = require("react-grid-layout") as ReactGridLayout
should workGrantas33
03/09/2020, 4:24 PM@JsName("WidthProvider")
on top of the WidthProvider class declaration should doRoger Kreienbühl
03/09/2020, 4:25 PMRoger Kreienbühl
03/09/2020, 4:25 PMGrantas33
03/09/2020, 4:27 PMRoger Kreienbühl
03/10/2020, 1:15 PMval RGL = kotlinext.js.require("react-grid-layout")
val WidthProvider = kotlinext.js.require("react-grid-layout").WidthProvider
val ReactGridLayout: RClass<ReactGridLayoutProps> = WidthProvider(RGL) as RClass<ReactGridLayoutProps>
Thanks for your help :-)