简体   繁体   中英

How to access global state in react redux

I am just curious if there is a way to access the global state in redux from my component without using mapStateToProps .

Thanks.

you can make use of the useSelector hook from the react-redux library to access the store without mapping it to your props.

you can use:

  • mapDispatchToProps
  • mergeProps (this one will give you what you want)
  • options

in the connect function provided by react-redux

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM