-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Introduce pre-typed hooks via hook.withTypes<RootState>()
method
#2114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
21600bd
Initial implementation of `withTypes`
aryaemami59 3dc456d
Remove `UseSelector` overload
aryaemami59 df1ad38
Add `IsEqual` type utility for type tests
aryaemami59 b0831d2
Add type tests for `withTypes`
aryaemami59 1b2b8f1
Remove extra comments
aryaemami59 f3af0b9
Add `hooks.withTypes.test-d.tsx` type test file
aryaemami59 e747c63
Add `hooks.withTypes.test.tsx` to test runtime behavior
aryaemami59 0f65c2a
Add JSDocs for `useSelector`
aryaemami59 0e60aa7
Add JSDocs for `useDispatch`
aryaemami59 8f84eb9
Export `UseDispatch` type and organize exports
aryaemami59 4360ff4
Add JSDocs for `useStore`
aryaemami59 7cf1383
Add `hooks.withTypes()` to docs
aryaemami59 78cdeac
Merge branch 'master' of https://github.com/reduxjs/react-redux into …
aryaemami59 349e0f0
Remove unused `TypedUseSelectorHook` imports
aryaemami59 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,51 @@ | ||
import Provider from './components/Provider' | ||
import type { ProviderProps } from './components/Provider' | ||
import connect from './components/connect' | ||
import type { | ||
export type { | ||
Connect, | ||
ConnectProps, | ||
ConnectedProps, | ||
} from './components/connect' | ||
import type { | ||
SelectorFactory, | ||
Selector, | ||
MapStateToProps, | ||
MapStateToPropsFactory, | ||
MapStateToPropsParam, | ||
MapDispatchToPropsFunction, | ||
MapDispatchToProps, | ||
MapDispatchToPropsFactory, | ||
MapDispatchToPropsParam, | ||
MapDispatchToPropsNonObject, | ||
MergeProps, | ||
} from './connect/selectorFactory' | ||
import { ReactReduxContext } from './components/Context' | ||
import type { ReactReduxContextValue } from './components/Context' | ||
|
||
import { useDispatch, createDispatchHook } from './hooks/useDispatch' | ||
import { useSelector, createSelectorHook } from './hooks/useSelector' | ||
import { useStore, createStoreHook } from './hooks/useStore' | ||
|
||
import shallowEqual from './utils/shallowEqual' | ||
import type { Subscription } from './utils/Subscription' | ||
|
||
import Provider from './components/Provider' | ||
import { defaultNoopBatch } from './utils/batch' | ||
|
||
export * from './types' | ||
export { ReactReduxContext } from './components/Context' | ||
export type { ReactReduxContextValue } from './components/Context' | ||
|
||
export type { ProviderProps } from './components/Provider' | ||
|
||
export type { | ||
ProviderProps, | ||
SelectorFactory, | ||
Selector, | ||
MapStateToProps, | ||
MapStateToPropsFactory, | ||
MapStateToPropsParam, | ||
Connect, | ||
ConnectProps, | ||
ConnectedProps, | ||
MapDispatchToPropsFunction, | ||
MapDispatchToProps, | ||
MapDispatchToPropsFactory, | ||
MapDispatchToPropsParam, | ||
MapDispatchToPropsFunction, | ||
MapDispatchToPropsNonObject, | ||
MapDispatchToPropsParam, | ||
MapStateToProps, | ||
MapStateToPropsFactory, | ||
MapStateToPropsParam, | ||
MergeProps, | ||
ReactReduxContextValue, | ||
Subscription, | ||
} | ||
Selector, | ||
SelectorFactory, | ||
} from './connect/selectorFactory' | ||
|
||
export { createDispatchHook, useDispatch } from './hooks/useDispatch' | ||
export type { UseDispatch } from './hooks/useDispatch' | ||
|
||
export { createSelectorHook, useSelector } from './hooks/useSelector' | ||
export type { UseSelector } from './hooks/useSelector' | ||
|
||
export { createStoreHook, useStore } from './hooks/useStore' | ||
export type { UseStore } from './hooks/useStore' | ||
|
||
export type { Subscription } from './utils/Subscription' | ||
|
||
export * from './types' | ||
|
||
/** | ||
* @deprecated As of React 18, batching is enabled by default for ReactDOM and React Native. | ||
* This is now a no-op that immediately runs the callback. | ||
*/ | ||
const batch = defaultNoopBatch | ||
|
||
export { | ||
Provider, | ||
ReactReduxContext, | ||
connect, | ||
useDispatch, | ||
createDispatchHook, | ||
useSelector, | ||
createSelectorHook, | ||
useStore, | ||
createStoreHook, | ||
shallowEqual, | ||
batch, | ||
} | ||
export { Provider, batch, connect, shallowEqual } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.