useStore.d.ts 1.1 KB

1234567891011121314151617181920212223242526
  1. import type { Context } from 'react';
  2. import type { Action as BasicAction, AnyAction, Store } from 'redux';
  3. import type { ReactReduxContextValue } from '../components/Context';
  4. /**
  5. * Hook factory, which creates a `useStore` hook bound to a given context.
  6. *
  7. * @param {React.Context} [context=ReactReduxContext] Context passed to your `<Provider>`.
  8. * @returns {Function} A `useStore` hook bound to the specified context.
  9. */
  10. export declare function createStoreHook<S = unknown, A extends BasicAction = AnyAction>(context?: Context<ReactReduxContextValue<S, A>>): <State = S, Action extends BasicAction<any> = A>() => Store<State, Action>;
  11. /**
  12. * A hook to access the redux store.
  13. *
  14. * @returns {any} the redux store
  15. *
  16. * @example
  17. *
  18. * import React from 'react'
  19. * import { useStore } from 'react-redux'
  20. *
  21. * export const ExampleComponent = () => {
  22. * const store = useStore()
  23. * return <div>{store.getState()}</div>
  24. * }
  25. */
  26. export declare const useStore: <State = unknown, Action extends BasicAction<any> = AnyAction>() => Store<State, Action>;