0

I am learning react-native, i have 3 screen login screen, Home screen and Profile screen. Here i need to store my user name from login screen using redux, and i need to get that user name in profile screen. How can achieve this. here my sample code. action.js

          const GET_USER="GET_USER";
            export const getUser = user => ({
                type: 'GET_USER',
                payload: user,
              });    
            export default getUser

        reducer.js

            const user = (state = {}, action) => {
                switch (action.type) {
                  case 'GET_USER':
                    return action.payload;
                  default:
                    return state;
                }
              };   

              export default user;        
user
  • 1,659
  • 1
  • 18
  • 25
  • Probably duplicated: https://stackoverflow.com/questions/42571794/pass-data-between-independent-component-react-and-redux – Oleg Sep 24 '19 at 13:29
  • Possible duplicate of [What is the difference between using constructor vs getInitialState in React / React Native?](https://stackoverflow.com/questions/30668326/what-is-the-difference-between-using-constructor-vs-getinitialstate-in-react-r) – Mikev Sep 24 '19 at 13:54

0 Answers0