I think I found a bug (Not sure) When extending ...
# react
a
I think I found a bug (Not sure) When extending
RComponent
and you
override
methods with arguments that are called from
react
directly (i.e.
componentDidUpdate(prevProps,prevState,snapshot)
or
componentWillReceiveProps(nextProps)
), generated
javascript
code always throws a
ClassCastException
. Lets take a look at
componentWillReceiveProps(next)
. The
IR Compiler
generates
javascript
code similar to this
Copy code
PaginatedGridComp.prototype.componentWillReceiveProps = function (nextProps) {
  return this.componentWillReceiveProps_17(nextProps instanceof Props_19 ? nextProps : THROW_CCE());
};
Since
react
creates
nextProps
internally, the check
nextProps instanceof Props_19
always fails. Hence it throws
CCE
Is there a work around to this problem? IR Compiler Backend
m
Your component’s
Props
must be
external
.
a
I figured. And marking it as
@JsExport
didn't solve the issue at all. However, my use case need a class for my
Props
m
That’s not possible with
kotlin-react
. You’ll have to wrap your class props in another
RProps
interface that’s
external
. My library does that automatically and thus supports regular classes als Props. But it intentionally only supports functional components: https://github.com/fluidsonic/fluid-react