score:1
open
will be in props
not in state
change your render to this
<Dialog title="Welcome to the React App!" actions={actions} open={this.props.open} ></Dialog>
also in mapStateToProps
function open
value will be in state object so you don't need the second parameter in the function
function mapStateToProps(state) {
return {
open: state.checkPassword.open,
};
}
score:1
When you are using redux
and reading the value from store
you need to use it from props
in your component. In short you should not have a state
that is directly derivable from props
. Change your component to below and it should work
class StartDialog extends Component {
render() {
const actions = [ <FlatButton label="Submit" onClick={this.props.checkPassword} /> ];
return (
<Dialog title="Welcome to the React App!" actions={actions} open={this.props.open} ></Dialog>
);
}
}
Also in your mapStateToProps you need to access the state correctly, If you are using combineReducers, you need to access the open value from the corresponding reducer
So if you use combineReducer
like
const reducers = combineReducer({
checkPassword:checkpasswordReducer
})
you need to use your mapStateToProps
function like
function mapStateToProps(state) {
return {
open: state.checkPassword.open,
};
}
Source: stackoverflow.com
Related Query
- Pass a state value from redux reducer to another reducer
- Redux. Pass state value to reducer
- change value of property in state reducer redux
- Pass Redux selector value to react state without rerendering in useEffect
- Not able to change second value of an array in state with conditional statement in reducer --- Redux
- Pass state from one reducer to another in Redux
- How can I set input value to the state in redux reducer file?
- Read Store's Initial State in Redux Reducer
- React + Redux - Input onChange is very slow when typing in when the input have a value from the state
- Redux Toolkit: state showing as Proxy / undefined within reducer
- How can I get the state value in the reducer of createSlice?
- How do I call setState with the previous state plus an additional value in a redux connected controlled component?
- How to pass redux state to sub routes?
- React Redux pass state as props to component
- Format date in Redux Reducer before it hits state
- redux - reducer state is blank
- Access other parts of state in Redux reducer
- Redux state props value is undefined
- A component is changing the default value state of an uncontrolled Slider after being initialized. Material UI Slider with Redux State
- Replacing new state in react redux reducer without making a copy
- How change value of nested array in redux reducer
- Reactjs Redux should we create sub reducer for every object in the state tree?
- react-native pass state globally using redux
- Is it ok to pass the entire Redux state object into a React component?
- How to update state of a component with value from reducer state in react-redux?
- Redux reducer, check if value exists in state array and update state
- React: How to pass State value to another component and use it to render a component
- Change value of a key in array of objects in redux reducer
- Common loading state reducer with Redux toolkit
- Redux Reducer that simply returns an action's value and not a state?
More Query from same tag
- ReactJS Add to Object that is a State
- Form inline not working as expected with React-Bootstrap
- Issue wtih exit property - framer motion
- React Webpack not rebuilding when edited file outside docker container (on mac)
- JSX mapping arrays stored inside a dynamic object (Next.js)
- I am using React Bootstrap <Container> tag. I want to fix it's width to default 1140 px on large devices but its going out of range to 1296 px
- How to stop a script completely when its tag is removed
- React-FontAwesome icon doesn't appear when favicon is set
- Why does react-router treat a regex `path` correctly, but throws an error at the same time?
- firestoreConnect Error: Collection is required to build query name
- Effective way if updating SQL Data Retrieved in ReactJS
- issues with progress bar files uploads via reactjs
- array not cleared when setting it to []
- How do i properly use useEffect for a async fetch call with react? react-hooks/exhaustive-deps
- Why Enzyme not load style from React component?
- Why you can't render from 2 JSX element?
- Http 404 on Azure Websites for react app
- How to use html js library inside react app
- How to pass a plain object to the permissions of CASL (React)
- Getting this with when I send a post request with an image: Error: Request failed with status code 409
- Is there a way to pass an Apollo query selection through react props?
- How to strip testing code when React JS is minified by for production?
- Cypress: Not able to stub with a basic example. What might i be missing?
- Change color of Bootstrap Delete Text X Icon in FormControl
- Pouchdb db `allDocs` iteration not returning value in Reactjs to another file
- responsive div height on conditional rendering?
- Why files are not being uploaded in the back-end from react-front-end
- How to test api calls within redux-saga
- Passing an array of object to useState throws this error Objects are not valid as a React child (found: object with keys {id, name})
- TypeError: Cannot read property 'map' of undefined but state has been stored