Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package tanstack.react.router

import kotlinx.js.JsPlainObject
import js.array.ReadonlyArray

@JsPlainObject
internal /* raw */
external interface UseMatchesOptions<T> {
val select: Select<ReadonlyArray<RouteMatch>, T>?
val structuralSharing: Boolean?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package tanstack.react.router

import js.array.ReadonlyArray

fun useMatches(): ReadonlyArray<RouteMatch> =
useMatches(UseMatchesOptions())

fun <T> useMatches(
select: Select<ReadonlyArray<RouteMatch>, T>,
): T =
useMatches(UseMatchesOptions(select = select))

fun <T> useMatches(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need this overload?

select: Select<ReadonlyArray<RouteMatch>, T>,
structuralSharing: Boolean,
): T =
useMatches(UseMatchesOptions(select = select, structuralSharing = structuralSharing))
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@file:JsModule("@tanstack/react-router")

package tanstack.react.router

/**
* The useMatches hook returns the router's complete presented array of RouteMatch objects regardless of its caller's position in the component tree. The array can include still-loading descendants or matches below a pending/error/not-found render boundary.
*
* Options:
* - `select`: If supplied, this function will be called with the route matches and the return value will be returned from useMatches. This value will also be used to determine if the hook should re-render its parent component using shallow equality checks.
* - `structuralSharing`: Configures whether structural sharing is enabled for the value returned by select.
*
* [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook)
*
* @return An array of RouteMatch objects (or selected value) for the matched route.
*/
internal /* raw */

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Missed overload without parameters?

external fun <T> useMatches(
options: UseMatchesOptions<T>,
): T