Skip to content

Commit

Permalink
Remove TypedStructuredSelectorCreator from docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed Jan 5, 2024
1 parent 140f38f commit 025c1a4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 68 deletions.
59 changes: 0 additions & 59 deletions website/docs/api/createStructuredSelector.mdx
Expand Up @@ -244,65 +244,6 @@ const nestedSelector = createStructuredSelector({
})
```

## `TypedStructuredSelectorCreator` (since 5.0.0)

A helper type that allows you to create a pre-typed version of <InternalLinks.CreateStructuredSelector /> tailored to the provided root state type.

{/* START: createStructuredSelector/createStructuredAppSelector.ts */}

<Tabs
groupId='language'
defaultValue='ts'
values={[
{label: 'TypeScript', value: 'ts'},
{label: 'JavaScript', value: 'js'},
]}>
<TabItem value='ts'>

```ts title="createStructuredSelector/createStructuredAppSelector.ts"
import type { TypedStructuredSelectorCreator } from 'reselect'
import { createStructuredSelector } from 'reselect'

interface RootState {
todos: {
id: number
completed: boolean
title: string
description: string
}[]
alerts: { id: number; read: boolean }[]
}

export const createStructuredAppSelector: TypedStructuredSelectorCreator<RootState> =
createStructuredSelector

const structuredSelector = createStructuredAppSelector({
// The `state` argument is correctly typed as `RootState`
todos: state => state.todos,
alerts: state => state.alerts
})
```

</TabItem>
<TabItem value='js'>

```js title="createStructuredSelector/createStructuredAppSelector.js"
import { createStructuredSelector } from 'reselect'

export const createStructuredAppSelector = createStructuredSelector

const structuredSelector = createStructuredAppSelector({
// The `state` argument is correctly typed as `RootState`
todos: state => state.todos,
alerts: state => state.alerts
})
```

</TabItem>
</Tabs>

{/* END: createStructuredSelector/createStructuredAppSelector.ts */}

## Defining a Pre-Typed <InternalLinks.CreateStructuredSelector>`createStructuredSelector`</InternalLinks.CreateStructuredSelector>

As of Reselect 5.0.2, you can create a "pre-typed" version of <InternalLinks.CreateStructuredSelector /> where the `state` type is predefined. This allows you to set the `state` type once, eliminating the need to specify it with every <InternalLinks.CreateStructuredSelector /> call.
Expand Down
1 change: 0 additions & 1 deletion website/docs/introduction/v5-summary.mdx
Expand Up @@ -31,7 +31,6 @@ Version 5.0.0 introduces several new features and improvements:
## Selector API Enhancements

- Removed the second overload of <InternalLinks.CreateStructuredSelector /> due to its susceptibility to runtime errors.
- Added the <InternalLinks.TypedStructuredSelectorCreator /> utility type to facilitate the creation of a pre-typed version of <InternalLinks.CreateStructuredSelector /> for your root state.

## Additional Functionalities

Expand Down
8 changes: 0 additions & 8 deletions website/src/components/InternalLinks.tsx
Expand Up @@ -89,13 +89,5 @@ export const InternalLinks = {
<Link to="/api/createStructuredSelector" title="createStructuredSelector">
<code>createStructuredSelector</code>
</Link>
)),
TypedStructuredSelectorCreator: memo(() => (
<Link
to="/api/createStructuredSelector#typedstructuredselectorcreator-since-500"
title="TypedStructuredSelectorCreator"
>
<code>TypedStructuredSelectorCreator</code>
</Link>
))
} as const satisfies Record<string, FC<Props>>

0 comments on commit 025c1a4

Please sign in to comment.