# Function useSelector

- useSelector<TState, Selected>(selector, equalityFn?): Selected

- A hook to access the redux store's state. This hook takes a selector function as an argument. The selector is called with the store state.

  This hook takes an optional equality comparison function as the second parameter that allows you to customize the way the selected state is compared to determine whether the component needs to be re-rendered.

  #### Type Parameters

  - TState = unknown
  - Selected = unknown

  #### Parameters

  - selector: ((state) => Selected)

    the selector function

    - - (state): Selected

      - #### Parameters

        - state: TState

        #### Returns Selected

  - `Optional` equalityFn: EqualityFn<Selected>

    the function that will be used to determine equality

  #### Returns Selected

  the selected state

  #### Example

      import React from 'react'
      import { useSelector } from 'react-redux'

      export const CounterComponent = () => {
        const counter = useSelector(state => state.counter)
        return <div>{counter}</div>
      }

  - Defined in common/temp/node_modules/.pnpm/react-redux@8.1.3_91ee3f21853aee6f4038f22086c31182/node_modules/react-redux/es/hooks/useSelector.d.ts:45
- useSelector<TState, Selected>(selector, options?): Selected

- A hook to access the redux store's state. This hook takes a selector function as an argument. The selector is called with the store state.

  This hook takes an optional equality comparison function as the second parameter that allows you to customize the way the selected state is compared to determine whether the component needs to be re-rendered.

  #### Type Parameters

  - TState = unknown
  - Selected = unknown

  #### Parameters

  - selector: ((state) => Selected)

    the selector function

    - - (state): Selected

      - #### Parameters

        - state: TState

        #### Returns Selected

  - `Optional` options: UseSelectorOptions<Selected>

  #### Returns Selected

  the selected state

  #### Example

      import React from 'react'
      import { useSelector } from 'react-redux'

      export const CounterComponent = () => {
        const counter = useSelector(state => state.counter)
        return <div>{counter}</div>
      }

  - Defined in common/temp/node_modules/.pnpm/react-redux@8.1.3_91ee3f21853aee6f4038f22086c31182/node_modules/react-redux/es/hooks/useSelector.d.ts:45