Skip to content

Commit

Permalink
Add useRefCallback hook (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
aerialist7 authored Jul 21, 2021
1 parent a921f52 commit 4867d12
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kotlin-react/src/main/kotlin/react/RefCallback.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
@file:Suppress("NOTHING_TO_INLINE")

package react

import org.w3c.dom.Element

external interface RefCallback<out T : Any> : Ref<T>

inline fun <T : Any> RefCallback(
callback: (T?) -> Unit,
): RefCallback<T> =
callback.unsafeCast<RefCallback<T>>()

inline fun <T : Element> useRefCallback(
vararg dependencies: dynamic,
noinline callback: (T?) -> Unit,
): RefCallback<T> =
RefCallback(rawUseCallback(callback, dependencies))

0 comments on commit 4867d12

Please sign in to comment.