Skip to content

Commit dec5c95

Browse files
Update redux-interview-questions.md
1 parent 2ca2749 commit dec5c95

1 file changed

Lines changed: 115 additions & 13 deletions

File tree

redux-interview-questions.md

Lines changed: 115 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,108 @@ The most of the applications has several top-level directories as below:
373373
<b><a href="#table-of-contents">↥ back to top</a></b>
374374
</div>
375375

376+
## Q. What is Redux DEVTools?
377+
378+
**Redux DevTools** is a browser extension and debugging platform that provides a powerful UI for inspecting every Redux action and state change in your application in real time. It is one of Redux\'s most compelling developer experience features.
379+
380+
**Installation:**
381+
382+
```bash
383+
# Chrome Extension
384+
https://chrome.google.com/webstore/detail/redux-devtools
385+
386+
# Firefox Extension
387+
https://addons.mozilla.org/en-US/firefox/addon/reduxdevtools/
388+
389+
# Standalone (Electron app — for React Native, non-browser, etc.)
390+
npm install --save-dev @redux-devtools/app
391+
```
392+
393+
**Setup with Redux Toolkit:**
394+
395+
Redux Toolkit\'s `configureStore()` automatically connects to the Redux DevTools Extension in development — no extra configuration needed:
396+
397+
```js
398+
import { configureStore } from '@reduxjs/toolkit';
399+
import counterReducer from './counterSlice';
400+
401+
// DevTools Extension is enabled automatically in development
402+
const store = configureStore({
403+
reducer: {
404+
counter: counterReducer,
405+
},
406+
});
407+
408+
export default store;
409+
```
410+
411+
**Setup without Redux Toolkit (legacy):**
412+
413+
```js
414+
import { createStore, compose } from 'redux';
415+
import rootReducer from './reducers';
416+
417+
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
418+
419+
const store = createStore(
420+
rootReducer,
421+
composeEnhancers()
422+
);
423+
```
424+
425+
**Key Features:**
426+
427+
| Feature | Description |
428+
|---------|-------------|
429+
| **Action log** | See every dispatched action with its `type` and `payload` in chronological order |
430+
| **State diff** | View exactly what changed in the state tree after each action |
431+
| **Time-travel debugging** | Click any past action to "jump" the app back to that exact state |
432+
| **Action replay** | Step forward and backward through actions like a video player |
433+
| **State inspector** | Inspect the full current state tree with an interactive JSON viewer |
434+
| **Dispatching actions** | Manually dispatch actions from the DevTools panel |
435+
| **Import / Export** | Save and share a full session log (actions + state) as a JSON file |
436+
| **Chart view** | Visualize the state tree as a chart |
437+
| **Persist on page reload** | Optionally persist the action history across page refreshes |
438+
439+
**Panels Overview:**
440+
441+
**1. Inspector Tab (default):**
442+
- Left panel: action list — click any action to inspect it
443+
- Right panel: switches between **Action** (payload), **State** (full tree after action), and **Diff** (what changed)
444+
445+
**2. Log Monitor:**
446+
- Displays a running log of all actions and corresponding state changes in a compact format.
447+
448+
**3. Chart Tab:**
449+
- Renders the Redux state tree as an interactive diagram, useful for understanding the shape of nested state.
450+
451+
**Time-Travel Debugging:**
452+
453+
```
454+
Dispatch: ADD_TODO → state v1
455+
Dispatch: TOGGLE_TODO → state v2
456+
Dispatch: DELETE_TODO → state v3
457+
458+
Jump here → app instantly reverts to state v2
459+
```
460+
461+
**Disabling in production:**
462+
463+
Redux Toolkit automatically disables DevTools in production builds. For manual setup, guard it explicitly:
464+
465+
```js
466+
devTools: process.env.NODE_ENV !== 'production'
467+
```
468+
469+
**Reference:**
470+
471+
* *[https://github.com/reduxjs/redux-devtools](https://github.com/reduxjs/redux-devtools)*
472+
* *[https://redux.js.org/usage/configuring-your-store#using-redux-devtools-extension](https://redux.js.org/usage/configuring-your-store)*
473+
474+
<div align="right">
475+
<b><a href="#table-of-contents">↥ back to top</a></b>
476+
</div>
477+
376478
## # 4. REDUX DATA FLOW
377479

378480
<br/>
@@ -2144,7 +2246,7 @@ function LiveStock() {
21442246

21452247
```js
21462248
function UserDetails({ userId }) {
2147-
// Don't run the query if userId is not yet available
2249+
// Don\'t run the query if userId is not yet available
21482250
const { data: user } = useGetUserQuery(userId, {
21492251
skip: !userId,
21502252
})
@@ -2708,7 +2810,7 @@ const counterSlice = createSlice({
27082810
reducers: {
27092811
increment: (state) => {
27102812
// Redux Toolkit allows us to write "mutating" logic in reducers
2711-
// It doesn't actually mutate the state because it uses the Immer library
2813+
// It doesn\'t actually mutate the state because it uses the Immer library
27122814
state.value += 1;
27132815
},
27142816
decrement: (state) => {
@@ -3032,7 +3134,7 @@ export const fetchPostsWithCondition = createAsyncThunk(
30323134
if (state.posts.lastFetch) {
30333135
const timeSinceLastFetch = Date.now() - state.posts.lastFetch;
30343136
if (timeSinceLastFetch < 60000) { // 1 minute
3035-
return rejectWithValue('Too soon to refetch');
3137+
return rejectWithValue('too soon to refetch');
30363138
}
30373139
}
30383140

@@ -3052,7 +3154,7 @@ export const fetchPostsWithCondition = createAsyncThunk(
30523154
condition: (arg, { getState }) => {
30533155
const state = getState();
30543156
if (state.posts.loading === 'pending') {
3055-
// Already fetching, don't fetch again
3157+
// Already fetching, don\'t fetch again
30563158
return false;
30573159
}
30583160
}
@@ -3340,7 +3442,7 @@ function todosReducer(state = [], action) {
33403442
**Example: With Immer (Redux Toolkit)**
33413443
33423444
```js
3343-
// Redux Toolkit - using Immer's draft state
3445+
// Redux Toolkit - using Immer\'s draft state
33443446
import { createSlice } from '@reduxjs/toolkit';
33453447

33463448
const todosSlice = createSlice({
@@ -3437,8 +3539,8 @@ const blogSlice = createSlice({
34373539
34383540
**Important Rules:**
34393541
3440-
1. **Either mutate OR return** - Don't do both in the same reducer
3441-
2. **Don't return undefined** - Always return state or nothing
3542+
1. **Either mutate OR return** - Don\'t do both in the same reducer
3543+
2. **Don\'t return undefined** - Always return state or nothing
34423544
34433545
```js
34443546
// ✅ GOOD - Mutate the draft
@@ -3459,7 +3561,7 @@ reducers: {
34593561
reducers: {
34603562
increment: (state) => {
34613563
state.value += 1;
3462-
return state; // Don't do this!
3564+
return state; // Don\'t do this!
34633565
}
34643566
}
34653567

@@ -3591,7 +3693,7 @@ const store = configureStore({
35913693
35923694
## Q. How to migrate from Redux to Redux Toolkit?
35933695
3594-
Migrating from traditional Redux to Redux Toolkit can be done gradually. You don't need to rewrite everything at once.
3696+
Migrating from traditional Redux to Redux Toolkit can be done gradually. You don\'t need to rewrite everything at once.
35953697
35963698
**Migration Strategy:**
35973699
@@ -3937,7 +4039,7 @@ MVC can be interpreted or modified in many ways to fit a particular framework or
39374039
* Separating the presentation from the model: enables implementation of different UIs and better testability
39384040
* Separating the controller from the view: most useful with web interfaces and not commonly used in most GUI frameworks
39394041
3940-
In general, MVC makes no assumptions about whether data flow within an application should be unidirectional or bidirectional. In server Side, MVC is good, but in Client side most of the JS frameworks provide data binding support which let the view can talk with model directly, It shoudn\'t be, Many times it become hard to debug something as there are scope for a property being changed by many ways.
4042+
In general, MVC makes no assumptions about whether data flow within an application should be unidirectional or bidirectional. In server Side, MVC is good, but in Client side most of the JS frameworks provide data binding support which let the view can talk with model directly, It should not be, Many times it become hard to debug something as there are scope for a property being changed by many ways.
39414043
39424044
**2. Flux:**
39434045
@@ -4233,7 +4335,7 @@ import CommentReducer from './CommentReducer';
42334335
*/
42344336

42354337
const appReducer = combineReducers({
4236-
/* your app's top-level reducers */
4338+
/* your app\'s top-level reducers */
42374339
users: UsersReducer,
42384340
orders: OrderReducer,
42394341
notifications: NotificationReducer,
@@ -4364,7 +4466,7 @@ class TodoListContainer extends Component {
43644466

43654467
const { dispatch } = props
43664468

4367-
// Here's a good use case for bindActionCreators:
4469+
// Here\'s a good use case for bindActionCreators:
43684470
// You want a child component to be completely unaware of Redux.
43694471
// We create bound versions of these functions now so we can
43704472
// pass them down to our child later.
@@ -4381,7 +4483,7 @@ class TodoListContainer extends Component {
43814483
// Injected by react-redux:
43824484
let { dispatch } = this.props
43834485

4384-
// Note: this won't work:
4486+
// Note: this won\'t work:
43854487
// TodoActionCreators.addTodo('Use Redux')
43864488

43874489
// You're just calling a function that creates an action.

0 commit comments

Comments
 (0)