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

Commit 6f5d8b0

Browse files
andrewarrowSergey Mashkov
authored andcommitted
adding componentDidUpdate
1 parent d4999f6 commit 6f5d8b0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

frontend/src/org/jetbrains/react/ReactComponent.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ abstract class ReactComponent<P : RProps, S : RState> : ReactExtensionProvider {
9393

9494
}
9595

96-
open fun componentDidUpdate(prevProps: P, prevState: S) {
96+
open fun componentDidUpdate(prevProps: RProps, prevState: RState) {
9797

9898
}
9999

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

187187
@JsName("componentDidUpdate")
188-
fun componentDidUpdate(prevProps: P, prevState: S) {
188+
fun componentDidUpdate(prevProps: RProps, prevState: RState) {
189+
subscribers.forEach {
190+
it.reactComponentDidUpdate(prevProps, prevState)
191+
}
189192
delegate.componentDidUpdate(prevProps, prevState)
190193
}
191194

frontend/src/org/jetbrains/react/ReactExtensions.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import kotlin.reflect.*
66
interface ReactComponentLifecycleListener {
77
fun reactComponentWillUpdate()
88

9+
fun reactComponentDidUpdate(prevProps: RProps, prevState: RState)
10+
911
fun reactComponentWillUnmount()
1012

1113
fun reactComponentWillMount()
@@ -25,6 +27,10 @@ abstract class BaseReactExtension(val provider: ReactExtensionProvider) {
2527
componentWillUpdate()
2628
}
2729

30+
override fun reactComponentDidUpdate(prevProps: RProps, prevState: RState) {
31+
componentDidUpdate(prevProps, prevState)
32+
}
33+
2834
override fun reactComponentWillUnmount() {
2935
provider.unsubscribe(this)
3036
componentWillUnmount()
@@ -43,6 +49,8 @@ abstract class BaseReactExtension(val provider: ReactExtensionProvider) {
4349
provider.subscribe(listener)
4450
}
4551

52+
open fun componentDidUpdate(prevProps: RProps, prevState: RState) {}
53+
4654
open fun componentWillUpdate() {}
4755

4856
open fun componentWillUnmount() {}

0 commit comments

Comments
 (0)