Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

adding componentDidUpdate #16

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions frontend/src/org/jetbrains/react/ReactComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ abstract class ReactComponent<P : RProps, S : RState> : ReactExtensionProvider {

}

open fun componentDidUpdate(prevProps: P, prevState: S) {
open fun componentDidUpdate(prevProps: RProps, prevState: RState) {

}

Expand Down Expand Up @@ -185,7 +185,10 @@ class ReactComponentWrapper<K, P : RProps, S : RState>(var props: P, val updater
}

@JsName("componentDidUpdate")
fun componentDidUpdate(prevProps: P, prevState: S) {
fun componentDidUpdate(prevProps: RProps, prevState: RState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why had you changed generic types to exact ones?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only way I could get it to compile. But feel free to change. My only goal was getting that event to fire and it wasn't without this change.

subscribers.forEach {
it.reactComponentDidUpdate(prevProps, prevState)
}
delegate.componentDidUpdate(prevProps, prevState)
}

Expand Down
8 changes: 8 additions & 0 deletions frontend/src/org/jetbrains/react/ReactExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import kotlin.reflect.*
interface ReactComponentLifecycleListener {
fun reactComponentWillUpdate()

fun reactComponentDidUpdate(prevProps: RProps, prevState: RState)

fun reactComponentWillUnmount()

fun reactComponentWillMount()
Expand All @@ -25,6 +27,10 @@ abstract class BaseReactExtension(val provider: ReactExtensionProvider) {
componentWillUpdate()
}

override fun reactComponentDidUpdate(prevProps: RProps, prevState: RState) {
componentDidUpdate(prevProps, prevState)
}

override fun reactComponentWillUnmount() {
provider.unsubscribe(this)
componentWillUnmount()
Expand All @@ -43,6 +49,8 @@ abstract class BaseReactExtension(val provider: ReactExtensionProvider) {
provider.subscribe(listener)
}

open fun componentDidUpdate(prevProps: RProps, prevState: RState) {}

open fun componentWillUpdate() {}

open fun componentWillUnmount() {}
Expand Down