Hello. I'm trying to achieve simple "Slide up" ani...
# javascript
r
Hello. I'm trying to achieve simple "Slide up" animation in Kotlin with official React mui wrappers, but I cannot find any example of how to do it. JS Code looks like this:
Copy code
const Transition = React.forwardRef(function Transition(
  props: TransitionProps & {
    children: React.ReactElement<any, any>;
  },
  ref: React.Ref<unknown>,
) {
  return <Slide direction="up" ref={ref} {...props} />;
});
And mine attempt:
Copy code
val transition = forwardRef<Any, PropsWithRef<Any>> { propsWithRef, ref ->
            Slide {
                attrs.ref = ref
                attrs.direction = SlideDirection.up
                Object.assign(this, propsWithRef)
            }
        }

        Dialog {
            fullWidth = true
            fullScreen = true
...
But it throws error "Cannot read properties of undefined (reading 'ref')" Can someone guide me how to use forwardRef in Kotlin? Thanks!
a
@turansky ^^
t
For non-legacy wrappers example is here
r
Thanks, I'll try to apply this on mui Transition
t
Also in modern wrappers:
Copy code
// in legacy
Object.assign(this, props)

// in modern
+props
r
+props didin't work there because type mismatch, and still I see that I cannot use
Copy code
val Transition = ForwardRef<_, TransitionProps> {
because TransitionProps is just a "Props" not a PropsWithRef. Is there any example of how to use mui Transitions? I see you are one of contributiors to "kotlin-mui-showcase" so maybe you have an idea how to implement custom transition to dialog?
t
cc @aerialist
Copy code
external interface MyTransitionProps : TransitionProps, PropsWithref<>
From example looks like you need custom props
TransitionProps
- your custom interface?
r
No, its from mui:
Copy code
package mui.material.transitions

external interface TransitionProps : react.Props
t
For custom components it's recommended to create custom props interface (your case)
r
Okey I ll try, thanks!