diff --git a/src/services/createRoute.spec.ts b/src/services/createRoute.spec.ts index d045588..314b824 100644 --- a/src/services/createRoute.spec.ts +++ b/src/services/createRoute.spec.ts @@ -52,7 +52,7 @@ test('given parent, query is combined', () => { }) }) -test('given parent, state is combined into stateParams', () => { +test('given parent, state is combined into state', () => { const parent = createRoute({ state: { foo: Number, @@ -66,7 +66,7 @@ test('given parent, state is combined into stateParams', () => { }, }) - expect(child.stateParams).toMatchObject({ + expect(child.state).toMatchObject({ foo: Number, bar: String, }) @@ -83,7 +83,7 @@ test('given parent and child without state, state matches parent', () => { parent: parent, }) - expect(child.stateParams).toMatchObject({ + expect(child.state).toMatchObject({ foo: Number, }) }) diff --git a/src/services/createRoute.ts b/src/services/createRoute.ts index 29ee924..41a9110 100644 --- a/src/services/createRoute.ts +++ b/src/services/createRoute.ts @@ -41,7 +41,7 @@ export function createRoute< const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta, const TState extends Record = Record ->(options: CreateRouteOptions & WithHooks & WithoutComponents & WithParent & (WithState | WithoutState)): Route>, Host<'', {}>, CombinePath>, CombineQuery>, CombineMeta, CombineState> +>(options: CreateRouteOptions & WithHooks & WithoutComponents & WithParent & (WithState | WithoutState)): Route>, Host<'', {}>, CombinePath>, CombineQuery>, CombineMeta, CombineState> export function createRoute< TComponent extends Component, @@ -60,7 +60,7 @@ export function createRoute< const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta, const TState extends Record = Record ->(options: CreateRouteOptions & WithHooks & WithComponent> & WithParent & (WithState | WithoutState)): Route>, Host<'', {}>, CombinePath>, CombineQuery>, CombineMeta, CombineState> +>(options: CreateRouteOptions & WithHooks & WithComponent> & WithParent & (WithState | WithoutState)): Route>, Host<'', {}>, CombinePath>, CombineQuery>, CombineMeta, CombineState> export function createRoute< TComponents extends Record, @@ -79,14 +79,14 @@ export function createRoute< const TQuery extends string | Query | undefined = undefined, const TMeta extends RouteMeta = RouteMeta, const TState extends Record = Record ->(options: CreateRouteOptions & WithHooks & WithComponents> & WithParent & (WithState | WithoutState)): Route>, Host<'', {}>, CombinePath>, CombineQuery>, CombineMeta, CombineState> +>(options: CreateRouteOptions & WithHooks & WithComponents> & WithParent & (WithState | WithoutState)): Route>, Host<'', {}>, CombinePath>, CombineQuery>, CombineMeta, CombineState> export function createRoute(options: CreateRouteOptions): Route { const key = toKey(options.name) const path = toPath(options.path) const query = toQuery(options.query) const meta = options.meta ?? {} - const stateParams = isWithState(options) ? options.state : {} + const state = isWithState(options) ? options.state : {} const rawRoute = markRaw({ meta: {}, state: {}, ...options }) const route = { @@ -96,7 +96,7 @@ export function createRoute(options: CreateRouteOptions): Route { path, query, meta, - stateParams, + state, depth: 1, host: host('', {}), }