简体   繁体   中英

How to access Redux store data from a functional component?

Currently I am working on a new page(functional component) that needs access to data from another page(class component).The data is store in the Redux store since I can display it with store.getState() in the class component. How would I access that data from the functional component?

There are several options.

  1. You use the useSelector hook
  2. You can wrap your component by the connect method
  3. You can pass store by props from parent to children and call getState method

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