score:3
Accepted answer
Simply get it from this.props
:
componentDidMount() {
console.log("mounted")
// the following line won't be bound to the store here...
const { actions } = this.props;
document.addEventListener("keydown", actions.naiveKeypress );
}
I believe you also need to unsubscribe from the keydown
event on component unmount event though. (even if it does not do that ever, just for sake of completeness and robustness).
Source: stackoverflow.com
Related Query
- addEventListener react redux with mapped dispatch
- Returning a dispatch with promises in action creators of react redux
- Dispatch is not a function - React Testing Library with React Redux Hooks
- React Redux - dispatch action with react hooks
- React Redux dispatch payload reaches case with data but doesnt save it
- React Router v4 with Redux - dispatch is not passed
- How to properly dispatch an axios delete with react redux
- Getting a TypeScript error with redux dispatch in my React app
- how to dispatch same action with different params in react redux
- React + Redux too many re-renders of mapped components with another API call
- Redux dispatch with React Final Form
- Dispatch in pure JS code using React with Redux Toolkit
- React router v6 useNavigate does not work with redux dispatch
- Execute function in React with Redux after the update of the STATE made by the dispatch of an action?
- How to dispatch a props from a button with React Redux
- how to prevent mapped Redux dispatch in props causing re-renders in React
- Nested components testing with Enzyme inside of React & Redux
- Prevent react component from rendering twice when using redux with componentWillMount
- Jest "No tests found, exiting with code 1" error on Windows 10 in React Redux application
- Cannot read property '.then' of undefined when testing async action creators with redux and react
- Dealing with local state in react and redux
- React Redux dispatch action after another action
- Fractal Project Structure with React and Redux - pros/cons
- React router v4 not working with Redux
- Async data flow in React App with Redux + ReactRouter?
- Calling an action from a different reducer with React and redux
- Using React forwardRef with Redux connect
- How do I use local state along with redux store state in the same react component?
- VueJs 2 with Vuex vs React with Redux
- Where to store WebRTC streams when building React app with redux
More Query from same tag
- Failed to compile 'dispatch' is not defined
- How to get a React Project running in Docker?
- Conditional Routes in react router dom v6
- how to optimize if both premitive and reference types in child component?
- Failed prop type: The prop `location` is marked as required in `PrivateRoute`, but its value is `undefined`
- Mock function not being called with react-testing-library, but original function is called
- React - import multiple svgs in a single file
- How to map through the array to generate dynamic form based on api response?
- How to put your object data from a form under specific properties
- Material UI AutoComplete not rendering on remote dataSource in React application
- Another resource to display the list
- this.setState() is not a function -> when trying to save response on state
- Getting toogleShow is not function when passing as props in react typescript functional component
- Async function is returning undefined
- How can I use the useState function as a toggle method?
- useReducer incrementing / decrementing 2 instead of 1
- How to spy (using Jest) on the child component method in enzyme?
- React-Redux - TypeError: state.menu is not iterable
- this.state.items.map is not a function. What might be the solution?
- pass in props into component to render
- Why does @chakra-ui/gatsby-plugin crashes gatsby?
- Is there any other way to implement a "listening" function without an infinite while loop?
- SCSS compilation issue in @material/button/_mixins.scss
- reactjs tailwind navigation bar with glassmorphism doesn't show nav bar links in desktop mode
- React Pagination Styling
- React router - Navigate inner pages with sub route
- setting a condition to hide and show content using React
- Confirmation modal connecting to redux store using mapStateToProps gives an ERROR
- ReactJS- Use slug instead of Id in the URL with React router
- How to connect to redux store from react-router onEnter hook?