Search⌘ K
AI Features

Connecting the Search Page

Explore how to connect the search page component to the Redux store in a React application. Understand using useDispatch and useSelector hooks to manage state centrally and dispatch actions. Learn to remove local state by replacing it with Redux store state for cleaner, scalable code and efficient updates.

Steps to connect search page to store

Let’s connect the search page to the store. To do that, perform the following steps:

  1. In SearchPage.tsx, let’s add the following import statements to import the hooks we need from React Redux and types from our store:

JavaScript (JSX)
import { useSelector, useDispatch } from 'react-redux';
import {
AppState,
searchingQuestionsAction,
searchedQuestionsAction,
} from './Store';
    ...