State Management Basics
Which of the following best describes the main purpose of Redux in a JavaScript application?
- To manage and centralize the application state
- To handle CSS styling
- To create reusable UI components
- To generate database schemas
- To increase server capacity
Store Fundamentals
In Redux, which object holds and manages the application state?
- Reducer
- Middleware
- Props
- Store
- Context
Actions in Redux
What is typically included in a Redux action object?
- A type property describing the action
- A reducer function
- Component lifecycle methods
- HTML markup
- Data fetchers
How Reducers Work
What is the main responsibility of a reducer function in Redux?
- To send HTTP requests
- To update and return the new state based on an action
- To connect the store to the UI
- To generate action types automatically
- To render server-side templates
Pure Functions
Why must Redux reducers be pure functions?
- To enable easy debugging and predictable state changes
- To increase network performance
- To allow direct DOM manipulation
- To automatically persist state to disk
- To prevent state synchronization
Dispatch Function
What is the main purpose of the dispatch function in Redux?
- To send actions to the store
- To fetch data from APIs
- To create new reducers
- To apply CSS styles
- To define state schemas
Single Source of Truth
Which Redux principle is illustrated by keeping all state in one centralized store?
- Loose coupling
- Single source of truth
- Multiple entry points
- Two-way data binding
- Global rendering
Immutability
What should a Redux reducer always avoid when updating state?
- Creating new objects
- Mutating the original state directly
- Returning a new state object
- Receiving the previous state as an argument
- Using switch statements
Action Creators
What does an action creator function typically return in Redux?
- A reducer function
- An action object
- A middleware
- A store instance
- A user interface element
Initial State
When is the initial state in a Redux store typically set?
- During the dispatch of an action
- When the reducer is first called
- When an action creator is defined
- When a component mounts
- After middleware registration
Combining Reducers
Which Redux utility is commonly used to organize multiple reducers into a single state tree?
- combineReducers
- concatReducers
- batchState
- pairUpReducers
- mergeActions
Selectors
What is a selector function commonly used for in Redux?
- To extract and return a slice of the state
- To create action types
- To combine reducers
- To dispatch actions
- To subscribe DOM events
Middleware Role
In Redux, what is the primary role of middleware?
- To extend the store's capabilities and handle side effects
- To create user interfaces
- To define state schemas
- To store HTML elements
- To replace reducer functions
State Updates
What happens each time an action is dispatched in a Redux application?
- The reducer runs and a new state is returned
- The DOM is immediately updated
- All CSS files are reloaded
- Middleware functions are removed
- Reducers are ignored
Subscribing to Store
Which method allows components to listen for state changes in the Redux store?
- listenStore
- useState
- subscribe
- fetch
- onStateChange