Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
136
rated 0 times [  142] [ 6]  / answers: 1 / hits: 27627  / 7 Years ago, wed, may 10, 2017, 12:00:00

I am new with Redux and newer with Redux devtool.



I made a simple app in which you click on a user and it display some data about him.



So basically in the state I have the current selected user.



But I don't know why the state keep beeing empty in redux devtool. (not in the app)



Here is where I create my store :



import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';

import App from './components/app';
import reducers from './reducers';

const createStoreWithMiddleware = applyMiddleware()(createStore);

ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
<App />
</Provider>
, document.querySelector('.container'));


And here is the action :



export const USER_SELECTED = 'USER_SELECTED'
export function selectUser(user){
return {
type : USER_SELECTED,
payload : user
}


}



Here is a reducer :



import {USER_SELECTED} from '../actions/index'
export default function (state = null,action){
switch(action.type){
case USER_SELECTED :
return action.payload
}

return state


}



And finally a call to the action :



this.props.selectUser(user)


The app works very well but I am probably missing something.



Thanks for your help !


More From » reactjs

 Answers
19

Did you add this line to your store?



window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()


github.com/zalmoxisus/redux-devtools-extension#11-basic-stor‌​e


[#57839] Sunday, May 7, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rocky

Total Points: 316
Total Questions: 108
Total Answers: 110

Location: Mali
Member since Sat, Feb 12, 2022
2 Years ago
;