kandi background
Explore Kits

redux-logger | Logger for Redux - Now maintained by LogRocket | State Container library

 by   LogRocket JavaScript Version: 3.0.6 License: MIT

 by   LogRocket JavaScript Version: 3.0.6 License: MIT

Download this library from

kandi X-RAY | redux-logger Summary

redux-logger is a JavaScript library typically used in User Interface, State Container, React applications. redux-logger has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
Now maintained by LogRocket!. LogRocket is a production Redux logging tool that lets you replay problems as if they happened in your own browser. Instead of guessing why errors happen, or asking users for screenshots and log dumps, LogRocket lets you replay Redux actions + state, network requests, console logs, and see a video of what the user saw.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • redux-logger has a medium active ecosystem.
  • It has 5509 star(s) with 333 fork(s). There are 71 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 39 open issues and 146 have been closed. On average issues are closed in 139 days. There are 22 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of redux-logger is 3.0.6
redux-logger Support
Best in #State Container
Average in #State Container
redux-logger Support
Best in #State Container
Average in #State Container

quality kandi Quality

  • redux-logger has 0 bugs and 0 code smells.
redux-logger Quality
Best in #State Container
Average in #State Container
redux-logger Quality
Best in #State Container
Average in #State Container

securitySecurity

  • redux-logger has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • redux-logger code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
redux-logger Security
Best in #State Container
Average in #State Container
redux-logger Security
Best in #State Container
Average in #State Container

license License

  • redux-logger is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
redux-logger License
Best in #State Container
Average in #State Container
redux-logger License
Best in #State Container
Average in #State Container

buildReuse

  • redux-logger releases are available to install and integrate.
  • Installation instructions, examples and code snippets are available.
redux-logger Reuse
Best in #State Container
Average in #State Container
redux-logger Reuse
Best in #State Container
Average in #State Container
Top functions reviewed by kandi - BETA

kandi has reviewed redux-logger and discovered the below as its top functions. This is intended to give you an instant insight into redux-logger implemented functionality, and help decide if they suit your requirements.

  • Style an output buffer
    • create a logger
      • Render a path .
        • Default action formatter .
          • Dynamically get log level .
            • Style the given kind .

              Get all kandi verified functions for this library.

              Get all kandi verified functions for this library.

              redux-logger Key Features

              Logger for Redux

              Usage

              copy iconCopydownload iconDownload
              import { applyMiddleware, createStore } from 'redux';
              
              // Logger with default options
              import logger from 'redux-logger'
              const store = createStore(
                reducer,
                applyMiddleware(logger)
              )
              
              // Note passing middleware as the third argument requires redux@>=3.1.0
              

              Options

              copy iconCopydownload iconDownload
              {
                predicate, // if specified this function will be called before each action is processed with this middleware.
                collapsed, // takes a Boolean or optionally a Function that receives `getState` function for accessing current store state and `action` object as parameters. Returns `true` if the log group should be collapsed, `false` otherwise.
                duration = false: Boolean, // print the duration of each action?
                timestamp = true: Boolean, // print the timestamp with each action?
              
                level = 'log': 'log' | 'console' | 'warn' | 'error' | 'info', // console's level
                colors: ColorsObject, // colors for title, prev state, action and next state: https://github.com/LogRocket/redux-logger/blob/master/src/defaults.js#L12-L18
                titleFormatter, // Format the title used when logging actions.
              
                stateTransformer, // Transform state before print. Eg. convert Immutable object to plain JSON.
                actionTransformer, // Transform action before print. Eg. convert Immutable object to plain JSON.
                errorTransformer, // Transform error before print. Eg. convert Immutable object to plain JSON.
              
                logger = console: LoggerObject, // implementation of the `console` API.
                logErrors = true: Boolean, // should the logger catch, log, and re-throw errors?
              
                diff = false: Boolean, // (alpha) show diff between states?
                diffPredicate // (alpha) filter function for showing states diff, similar to `predicate`
              }
              

              Log only in development

              copy iconCopydownload iconDownload
              const middlewares = [];
              
              if (process.env.NODE_ENV === `development`) {
                const { logger } = require(`redux-logger`);
              
                middlewares.push(logger);
              }
              
              const store = compose(applyMiddleware(...middlewares))(createStore)(reducer);
              

              Log everything except actions with certain type

              copy iconCopydownload iconDownload
              createLogger({
                predicate: (getState, action) => action.type !== AUTH_REMOVE_TOKEN
              });
              

              Collapse actions with certain type

              copy iconCopydownload iconDownload
              createLogger({
                collapsed: (getState, action) => action.type === FORM_CHANGE
              });
              

              Collapse actions that don't have errors

              copy iconCopydownload iconDownload
              createLogger({
                collapsed: (getState, action, logEntry) => !logEntry.error
              });
              

              Transform Immutable (without

              copy iconCopydownload iconDownload
              import { Iterable } from 'immutable';
              
              const stateTransformer = (state) => {
                if (Iterable.isIterable(state)) return state.toJS();
                else return state;
              };
              
              const logger = createLogger({
                stateTransformer,
              });
              

              Transform Immutable (with

              copy iconCopydownload iconDownload
              const logger = createLogger({
                stateTransformer: (state) => {
                  let newState = {};
              
                  for (var i of Object.keys(state)) {
                    if (Immutable.Iterable.isIterable(state[i])) {
                      newState[i] = state[i].toJS();
                    } else {
                      newState[i] = state[i];
                    }
                  };
              
                  return newState;
                }
              });
              

              Log batched actions

              copy iconCopydownload iconDownload
              import { createLogger } from 'redux-logger';
              
              const actionTransformer = action => {
                if (action.type === 'BATCHING_REDUCER.BATCH') {
                  action.payload.type = action.payload.map(next => next.type).join(' => ');
                  return action.payload;
                }
              
                return action;
              };
              
              const level = 'info';
              
              const logger = {};
              
              for (const method in console) {
                if (typeof console[method] === 'function') {
                  logger[method] = console[method].bind(console);
                }
              }
              
              logger[level] = function levelFn(...args) {
                const lastArg = args.pop();
              
                if (Array.isArray(lastArg)) {
                  return lastArg.forEach(item => {
                    console[level].apply(console, [...args, item]);
                  });
                }
              
                console[level].apply(console, arguments);
              };
              
              export default createLogger({
                level,
                actionTransformer,
                logger
              });
              

              Error: Node Sass does not yet support your current environment

              copy iconCopydownload iconDownload
              npm uninstall node-sass --save
              npm install sass --save
              
              sudo npm install -g n
              sudo n 14
              
              npm uninstall node-sass --save
              npm install node-sass --save
              
              npm uninstall node-sass --save
              npm install sass --save
              
              sudo npm install -g n
              sudo n 14
              
              npm uninstall node-sass --save
              npm install node-sass --save
              
              npm uninstall node-sass --save
              npm install sass --save
              
              sudo npm install -g n
              sudo n 14
              
              npm uninstall node-sass --save
              npm install node-sass --save
              

              java.lang.NoSuchMethodError: No virtual method setSkipClientToken(Z)V in class Lcom/facebook/GraphRequest;

              copy iconCopydownload iconDownload
              implementation 'com.facebook.android:facebook-marketing:[4,5)'
              
              implementation 'com.facebook.android:facebook-marketing:latest.release'
              
              implementation 'com.facebook.android:facebook-marketing:[4,5)'
              
              implementation 'com.facebook.android:facebook-marketing:latest.release'
              

              Redux-Logger - 'reducer' is not defined

              copy iconCopydownload iconDownload
              import { configureStore } from '@reduxjs/toolkit'
              
              import logger from 'redux-logger'
              
              import rootReducer from './reducer'
              
              const store = configureStore({
                reducer: rootReducer,
                middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(logger),
              })
              

              Error: Problem validating fields in app.json. Learn https://docs.expo.dev/workflow/configuration/ • Field: android.permissions[4] - should be string

              copy iconCopydownload iconDownload
              ...
                    [
                      "expo-media-library",
                      {
                        photosPermission: "Allow $(PRODUCT_NAME) to access your photos.",
                        savePhotosPermission: "Allow $(PRODUCT_NAME) to save photos.",
                        isAccessMediaLocationEnabled: "true",
                      },
                    ],
              ...
              

              Material ui TypeError: palette.theme undefined

              copy iconCopydownload iconDownload
              import List from '@mui/material/List'
              import ListItem from '@mui/material/ListItem'
              
              import List from '@material-ui/core/List';    
              import ListItem from '@material-ui/core/ListItem';
              
              import List from '@mui/material/List'
              import ListItem from '@mui/material/ListItem'
              
              import List from '@material-ui/core/List';    
              import ListItem from '@material-ui/core/ListItem';
              

              Typing dispatch on a redux store correctly when using multiple middleware

              copy iconCopydownload iconDownload
              import { configureStore } from '@reduxjs/toolkit'
              import { useDispatch } from 'react-redux'
              import rootReducer from './rootReducer'
              
              const store = configureStore({
                reducer: rootReducer,
              })
              
              export type AppDispatch = typeof store.dispatch
              export const useAppDispatch = () => useDispatch<AppDispatch>() // Export a hook that can be reused to resolve types
              
              export default store
              

              Redux-Saga: TypeError: Cannot read properties of undefined (reading 'data')

              copy iconCopydownload iconDownload
              export const loadUsersApi = () => {
                return axios.get("http://localhost:5000/users");
              };
              
              try {
                  const response = yield call(await loadUsersApi);
                  if (response.status === 200) {
                    yield delay(500);
                    yield put(loadUsersSuccess(response.data));
                  }
                } catch (error) {
                  yield put(loadUsersError(error.response.data));
                }
              
              import { createSlice } from '@reduxjs/toolkit'
              
              const initialState = {
                users: [],
                loading: false,
                success: false,
                error: false,
                message: ''
              }
              
              export const usersSlice = createSlice({
                name: 'users',
                initialState,
                // // The `reducers` field lets us define reducers and generate associated actions
                reducers: {
                  setUsers: (state, action) => {
                    // Redux Toolkit allows us to write "mutating" logic in reducers. It
                    // doesn't actually mutate the state because it uses the Immer library,
                    // which detects changes to a "draft state" and produces a brand new
                    // immutable state based off those changes
                    state.users = action.payload
                  },
                  setLoading: (state, action) => {
                    state.loading = action.payload
                  },
                  setSuccess: (state, action) => {
                    state.success = action.payload.status
                    state.message = action.payload.message
                  },
                  setError: (state, action) => {
                    state.error = action.payload.status
                    state.message = action.payload.message
                  }
                }
              })
              
              export const { setUsers, setLoading, setSuccess, setError, setMessage } = usersSlice.actions;
              
              // The function below is called a selector and allows us to select a value from
              // the state. Selectors can also be defined inline where they're used instead of
              // in the slice file. For example: `useSelector((state: RootState) => state.counter.value)`
              export const selectUsers = (state) => state.users.users
              export const selectLoading = (state) => state.users.loading
              export const selectSuccess = (state) => state.users.success
              export const selectError = (state) => state.users.error
              export const selectMessage = (state) => state.users.message
              
              export default usersSlice.reducer;
              
              import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit'
              import usersReducer from '../slices/users'
              
              export const store = configureStore({
                reducer: {
                  users: usersReducer
                },
                middleware: getDefaultMiddleware({
                  serializableCheck: false
                })
              })
              
              import { Provider } from 'react-redux'
              import { store } from '../app/store'
              
              export default function App() {
                return {
                  <>
                    <Provider store={store}>
                      {/* your content... */}    
                    </Provider>
                  </>
                }
              }
              
              import { useContext, useEffect } from 'react'
              import { useDispatch, useSelector } from 'react-redux'
              import { selectUsers, selectLoading, selectSuccess, selectError, selectMessage, setUsers, setLoading, setSuccess, setError } from '../slices/users'
              import axios from 'axios'
              
              export default function HomePage() {
                const dispatch = useDispatch()
                const users = useSelector(selectUser)
                const loading = useSelector(selectLoading)  
                const success = useSelector(selectSuccess)
                const error = useSelector(selectorError)
                const message = useSelector(selectorMessage)
              
                useEffect(() => {
                  async function init() {
                    dispatch(setLoading(true))
                    const response = await axios.get('http://localhost:5000/users')
                    
                    if(response?.status == 200) {
                      dispatch(setUsers(response?.data?.data))
                      dispatch(setSuccess({ status: true, message: 'Successfully get users data.' }))
                    } else {
                      dispatch(setError({ status: true, message: 'Failed to get data.' }))
                    }
              
                    dispatch(setLoading(false))
                  }
                  return init()
                }, [])
              
                return {
                  <>
                    {user}
                  </>
                }
              }
              
              import { createSlice } from '@reduxjs/toolkit'
              
              const initialState = {
                users: [],
                loading: false,
                success: false,
                error: false,
                message: ''
              }
              
              export const usersSlice = createSlice({
                name: 'users',
                initialState,
                // // The `reducers` field lets us define reducers and generate associated actions
                reducers: {
                  setUsers: (state, action) => {
                    // Redux Toolkit allows us to write "mutating" logic in reducers. It
                    // doesn't actually mutate the state because it uses the Immer library,
                    // which detects changes to a "draft state" and produces a brand new
                    // immutable state based off those changes
                    state.users = action.payload
                  },
                  setLoading: (state, action) => {
                    state.loading = action.payload
                  },
                  setSuccess: (state, action) => {
                    state.success = action.payload.status
                    state.message = action.payload.message
                  },
                  setError: (state, action) => {
                    state.error = action.payload.status
                    state.message = action.payload.message
                  }
                }
              })
              
              export const { setUsers, setLoading, setSuccess, setError, setMessage } = usersSlice.actions;
              
              // The function below is called a selector and allows us to select a value from
              // the state. Selectors can also be defined inline where they're used instead of
              // in the slice file. For example: `useSelector((state: RootState) => state.counter.value)`
              export const selectUsers = (state) => state.users.users
              export const selectLoading = (state) => state.users.loading
              export const selectSuccess = (state) => state.users.success
              export const selectError = (state) => state.users.error
              export const selectMessage = (state) => state.users.message
              
              export default usersSlice.reducer;
              
              import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit'
              import usersReducer from '../slices/users'
              
              export const store = configureStore({
                reducer: {
                  users: usersReducer
                },
                middleware: getDefaultMiddleware({
                  serializableCheck: false
                })
              })
              
              import { Provider } from 'react-redux'
              import { store } from '../app/store'
              
              export default function App() {
                return {
                  <>
                    <Provider store={store}>
                      {/* your content... */}    
                    </Provider>
                  </>
                }
              }
              
              import { useContext, useEffect } from 'react'
              import { useDispatch, useSelector } from 'react-redux'
              import { selectUsers, selectLoading, selectSuccess, selectError, selectMessage, setUsers, setLoading, setSuccess, setError } from '../slices/users'
              import axios from 'axios'
              
              export default function HomePage() {
                const dispatch = useDispatch()
                const users = useSelector(selectUser)
                const loading = useSelector(selectLoading)  
                const success = useSelector(selectSuccess)
                const error = useSelector(selectorError)
                const message = useSelector(selectorMessage)
              
                useEffect(() => {
                  async function init() {
                    dispatch(setLoading(true))
                    const response = await axios.get('http://localhost:5000/users')
                    
                    if(response?.status == 200) {
                      dispatch(setUsers(response?.data?.data))
                      dispatch(setSuccess({ status: true, message: 'Successfully get users data.' }))
                    } else {
                      dispatch(setError({ status: true, message: 'Failed to get data.' }))
                    }
              
                    dispatch(setLoading(false))
                  }
                  return init()
                }, [])
              
                return {
                  <>
                    {user}
                  </>
                }
              }
              
              import { createSlice } from '@reduxjs/toolkit'
              
              const initialState = {
                users: [],
                loading: false,
                success: false,
                error: false,
                message: ''
              }
              
              export const usersSlice = createSlice({
                name: 'users',
                initialState,
                // // The `reducers` field lets us define reducers and generate associated actions
                reducers: {
                  setUsers: (state, action) => {
                    // Redux Toolkit allows us to write "mutating" logic in reducers. It
                    // doesn't actually mutate the state because it uses the Immer library,
                    // which detects changes to a "draft state" and produces a brand new
                    // immutable state based off those changes
                    state.users = action.payload
                  },
                  setLoading: (state, action) => {
                    state.loading = action.payload
                  },
                  setSuccess: (state, action) => {
                    state.success = action.payload.status
                    state.message = action.payload.message
                  },
                  setError: (state, action) => {
                    state.error = action.payload.status
                    state.message = action.payload.message
                  }
                }
              })
              
              export const { setUsers, setLoading, setSuccess, setError, setMessage } = usersSlice.actions;
              
              // The function below is called a selector and allows us to select a value from
              // the state. Selectors can also be defined inline where they're used instead of
              // in the slice file. For example: `useSelector((state: RootState) => state.counter.value)`
              export const selectUsers = (state) => state.users.users
              export const selectLoading = (state) => state.users.loading
              export const selectSuccess = (state) => state.users.success
              export const selectError = (state) => state.users.error
              export const selectMessage = (state) => state.users.message
              
              export default usersSlice.reducer;
              
              import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit'
              import usersReducer from '../slices/users'
              
              export const store = configureStore({
                reducer: {
                  users: usersReducer
                },
                middleware: getDefaultMiddleware({
                  serializableCheck: false
                })
              })
              
              import { Provider } from 'react-redux'
              import { store } from '../app/store'
              
              export default function App() {
                return {
                  <>
                    <Provider store={store}>
                      {/* your content... */}    
                    </Provider>
                  </>
                }
              }
              
              import { useContext, useEffect } from 'react'
              import { useDispatch, useSelector } from 'react-redux'
              import { selectUsers, selectLoading, selectSuccess, selectError, selectMessage, setUsers, setLoading, setSuccess, setError } from '../slices/users'
              import axios from 'axios'
              
              export default function HomePage() {
                const dispatch = useDispatch()
                const users = useSelector(selectUser)
                const loading = useSelector(selectLoading)  
                const success = useSelector(selectSuccess)
                const error = useSelector(selectorError)
                const message = useSelector(selectorMessage)
              
                useEffect(() => {
                  async function init() {
                    dispatch(setLoading(true))
                    const response = await axios.get('http://localhost:5000/users')
                    
                    if(response?.status == 200) {
                      dispatch(setUsers(response?.data?.data))
                      dispatch(setSuccess({ status: true, message: 'Successfully get users data.' }))
                    } else {
                      dispatch(setError({ status: true, message: 'Failed to get data.' }))
                    }
              
                    dispatch(setLoading(false))
                  }
                  return init()
                }, [])
              
                return {
                  <>
                    {user}
                  </>
                }
              }
              
              import { createSlice } from '@reduxjs/toolkit'
              
              const initialState = {
                users: [],
                loading: false,
                success: false,
                error: false,
                message: ''
              }
              
              export const usersSlice = createSlice({
                name: 'users',
                initialState,
                // // The `reducers` field lets us define reducers and generate associated actions
                reducers: {
                  setUsers: (state, action) => {
                    // Redux Toolkit allows us to write "mutating" logic in reducers. It
                    // doesn't actually mutate the state because it uses the Immer library,
                    // which detects changes to a "draft state" and produces a brand new
                    // immutable state based off those changes
                    state.users = action.payload
                  },
                  setLoading: (state, action) => {
                    state.loading = action.payload
                  },
                  setSuccess: (state, action) => {
                    state.success = action.payload.status
                    state.message = action.payload.message
                  },
                  setError: (state, action) => {
                    state.error = action.payload.status
                    state.message = action.payload.message
                  }
                }
              })
              
              export const { setUsers, setLoading, setSuccess, setError, setMessage } = usersSlice.actions;
              
              // The function below is called a selector and allows us to select a value from
              // the state. Selectors can also be defined inline where they're used instead of
              // in the slice file. For example: `useSelector((state: RootState) => state.counter.value)`
              export const selectUsers = (state) => state.users.users
              export const selectLoading = (state) => state.users.loading
              export const selectSuccess = (state) => state.users.success
              export const selectError = (state) => state.users.error
              export const selectMessage = (state) => state.users.message
              
              export default usersSlice.reducer;
              
              import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit'
              import usersReducer from '../slices/users'
              
              export const store = configureStore({
                reducer: {
                  users: usersReducer
                },
                middleware: getDefaultMiddleware({
                  serializableCheck: false
                })
              })
              
              import { Provider } from 'react-redux'
              import { store } from '../app/store'
              
              export default function App() {
                return {
                  <>
                    <Provider store={store}>
                      {/* your content... */}    
                    </Provider>
                  </>
                }
              }
              
              import { useContext, useEffect } from 'react'
              import { useDispatch, useSelector } from 'react-redux'
              import { selectUsers, selectLoading, selectSuccess, selectError, selectMessage, setUsers, setLoading, setSuccess, setError } from '../slices/users'
              import axios from 'axios'
              
              export default function HomePage() {
                const dispatch = useDispatch()
                const users = useSelector(selectUser)
                const loading = useSelector(selectLoading)  
                const success = useSelector(selectSuccess)
                const error = useSelector(selectorError)
                const message = useSelector(selectorMessage)
              
                useEffect(() => {
                  async function init() {
                    dispatch(setLoading(true))
                    const response = await axios.get('http://localhost:5000/users')
                    
                    if(response?.status == 200) {
                      dispatch(setUsers(response?.data?.data))
                      dispatch(setSuccess({ status: true, message: 'Successfully get users data.' }))
                    } else {
                      dispatch(setError({ status: true, message: 'Failed to get data.' }))
                    }
              
                    dispatch(setLoading(false))
                  }
                  return init()
                }, [])
              
                return {
                  <>
                    {user}
                  </>
                }
              }
              

              React component won't update react-redux

              copy iconCopydownload iconDownload
              useEffect(() => {
                  if (region && region !== '') {
                    setRegionState(region)
                    setPageData(fakeData);
                  } else {
                    setPageData([{}]);
                  }
                }, [region]);
              

              TypeError: firebase__default.default.initializeApp is not a function when using initializeTestApp method

              copy iconCopydownload iconDownload
              "@firebase/rules-unit-testing": "^1.3.7"
              
              npm install
              
              "@firebase/rules-unit-testing": "^1.3.7"
              
              npm install
              

              React - How to stay on the same page even if it was refreshed?

              copy iconCopydownload iconDownload
              const INITIAL_STATE = {
               isLogin: localStorage.IS_LOGIN
              };
              
                useEffect(() => {
                  if (!isLogin) {
                    props.history.push("/login");
                  }
                }, [isLogin]);
              
                return isLogin;
              };
              
              const INITIAL_STATE = {
               isLogin: localStorage.IS_LOGIN
              };
              
                useEffect(() => {
                  if (!isLogin) {
                    props.history.push("/login");
                  }
                }, [isLogin]);
              
                return isLogin;
              };
              
              const userTypes = {
                SET_AUTH_PENDING: "SET_AUTH_PENDING",
                SET_CURRENT_USER: "SET_CURRENT_USER",
              };
              
              const setAuthPending = pending => ({
                type: userTypes.SET_AUTH_PENDING,
                payload: pending,
              });
              
              const INITIAL_STATE = {
                authPending: true,
                currentUser: null,
              };
              
              const userReducer = (state = INITIAL_STATE, action) => {
                switch (action.type) {
                  case userTypes.SET_CURRENT_USER:
                    return {
                      ...state,
                      authPending: false
                      currentUser: action.payload,
                    };
              
                  case userTypes.SET_AUTH_PENDING:
                    return {
                      ...state,
                      authPending: action.payload,
                    };
              
                  default:
                    return state;
                }
              };
              
              const App = (props) => {
                const {
                  setAuthPending, // <-- access action
                  setCurrentUser,
                  currentUser
                } = props;
              
                const admin = checkUserAdmin(currentUser);
                console.log(admin);
              
                useEffect(() => {
                  const unsubscribe = auth.onAuthStateChanged(async (userAuth) => {
                    setAuthPending(true); // <-- start auth pending
                    if (userAuth) {
                      const userRef = await handleUserProfile(userAuth);
                      userRef.onSnapshot((snapshot) => {
                        setCurrentUser({ // <-- will clear auth pending
                          id: snapshot.id,
                          ...snapshot.data(),
                        });
                      });
                    } else { 
                      setCurrentUser(null); // <-- clear user data and pending
                    }
                  });
              
                  return () => {
                    unsubscribe();
                  };
                }, []);
              
                return (
                  <div className="App">
                    <Switch>
                      ...
                    </Switch>
                  </div>
                );
              };
              
              const mapStateToProps = ({ user }) => ({
                currentUser: user.currentUser,
              });
              
              const mapDispatchToProps = {
                setAuthPending, // <-- wrap action creator in call to dispatch
                setCurrentUser,
              };
              
              const AuthRoute = props => {
                const { authPending, currentUser } = useSelector(state => state.user);
              
                if (authPending) {
                  return "Loading..."; // or maybe a loading spinner
                };
              
                return currentUser ? (
                  <Route {...props} />
                ) : (
                  <Redirect to="/login" />
                );
              };
              
              const AdminRoute = props => {
                const { authPending, currentUser } = useSelector(state => state.user);
              
                if (authPending) {
                  return "Loading..."; // or maybe a loading spinner
                };
              
                return checkUserAdmin(currentUser) ? (
                  <Route {...props} />
                ) : (
                  <Redirect to="/login" />
                );
              };
              
              <Switch>
                <Route
                  exact
                  path="/"
                  render={() => (
                    <MainLayout>
                      <Homepage />
                    </MainLayout>
                  )}
                />
                <Route
                  exact
                  path="/login"
                  render={() => (
                    <MainLayout>
                      <LoginPage />
                    </MainLayout>
                  )}
                />
                <AuthRoute
                  exact
                  path="/profile"
                  render={() => (
                    <MainLayout>
                      <ProfilePage />
                    </MainLayout>
                  )}
                />
                <AdminRoute
                  exact
                  path="/admin"
                  component={AdminHome}
                />
              </Switch>
              
              const userTypes = {
                SET_AUTH_PENDING: "SET_AUTH_PENDING",
                SET_CURRENT_USER: "SET_CURRENT_USER",
              };
              
              const setAuthPending = pending => ({
                type: userTypes.SET_AUTH_PENDING,
                payload: pending,
              });
              
              const INITIAL_STATE = {
                authPending: true,
                currentUser: null,
              };
              
              const userReducer = (state = INITIAL_STATE, action) => {
                switch (action.type) {
                  case userTypes.SET_CURRENT_USER:
                    return {
                      ...state,
                      authPending: false
                      currentUser: action.payload,
                    };
              
                  case userTypes.SET_AUTH_PENDING:
                    return {
                      ...state,
                      authPending: action.payload,
                    };
              
                  default:
                    return state;
                }
              };
              
              const App = (props) => {
                const {
                  setAuthPending, // <-- access action
                  setCurrentUser,
                  currentUser
                } = props;
              
                const admin = checkUserAdmin(currentUser);
                console.log(admin);
              
                useEffect(() => {
                  const unsubscribe = auth.onAuthStateChanged(async (userAuth) => {
                    setAuthPending(true); // <-- start auth pending
                    if (userAuth) {
                      const userRef = await handleUserProfile(userAuth);
                      userRef.onSnapshot((snapshot) => {
                        setCurrentUser({ // <-- will clear auth pending
                          id: snapshot.id,
                          ...snapshot.data(),
                        });
                      });
                    } else { 
                      setCurrentUser(null); // <-- clear user data and pending
                    }
                  });
              
                  return () => {
                    unsubscribe();
                  };
                }, []);
              
                return (
                  <div className="App">
                    <Switch>
                      ...
                    </Switch>
                  </div>
                );
              };
              
              const mapStateToProps = ({ user }) => ({
                currentUser: user.currentUser,
              });
              
              const mapDispatchToProps = {
                setAuthPending, // <-- wrap action creator in call to dispatch
                setCurrentUser,
              };
              
              const AuthRoute = props => {
                const { authPending, currentUser } = useSelector(state => state.user);
              
                if (authPending) {
                  return "Loading..."; // or maybe a loading spinner
                };
              
                return currentUser ? (
                  <Route {...props} />
                ) : (
                  <Redirect to="/login" />
                );
              };
              
              const AdminRoute = props => {
                const { authPending, currentUser } = useSelector(state => state.user);
              
                if (authPending) {
                  return "Loading..."; // or maybe a loading spinner
                };
              
                return checkUserAdmin(currentUser) ? (
                  <Route {...props} />
                ) : (
                  <Redirect to="/login" />
                );
              };
              
              <Switch>
                <Route
                  exact
                  path="/"
                  render={() => (
                    <MainLayout>
                      <Homepage />
                    </MainLayout>
                  )}
                />
                <Route
                  exact
                  path="/login"
                  render={() => (
                    <MainLayout>
                      <LoginPage />
                    </MainLayout>
                  )}
                />
                <AuthRoute
                  exact
                  path="/profile"
                  render={() => (
                    <MainLayout>
                      <ProfilePage />
                    </MainLayout>
                  )}
                />
                <AdminRoute
                  exact
                  path="/admin"
                  component={AdminHome}
                />
              </Switch>
              
              const userTypes = {
                SET_AUTH_PENDING: "SET_AUTH_PENDING",
                SET_CURRENT_USER: "SET_CURRENT_USER",
              };
              
              const setAuthPending = pending => ({
                type: userTypes.SET_AUTH_PENDING,
                payload: pending,
              });
              
              const INITIAL_STATE = {
                authPending: true,
                currentUser: null,
              };
              
              const userReducer = (state = INITIAL_STATE, action) => {
                switch (action.type) {
                  case userTypes.SET_CURRENT_USER:
                    return {
                      ...state,
                      authPending: false
                      currentUser: action.payload,
                    };
              
                  case userTypes.SET_AUTH_PENDING:
                    return {
                      ...state,
                      authPending: action.payload,
                    };
              
                  default:
                    return state;
                }
              };
              
              const App = (props) => {
                const {
                  setAuthPending, // <-- access action
                  setCurrentUser,
                  currentUser
                } = props;
              
                const admin = checkUserAdmin(currentUser);
                console.log(admin);
              
                useEffect(() => {
                  const unsubscribe = auth.onAuthStateChanged(async (userAuth) => {
                    setAuthPending(true); // <-- start auth pending
                    if (userAuth) {
                      const userRef = await handleUserProfile(userAuth);
                      userRef.onSnapshot((snapshot) => {
                        setCurrentUser({ // <-- will clear auth pending
                          id: snapshot.id,
                          ...snapshot.data(),
                        });
                      });
                    } else { 
                      setCurrentUser(null); // <-- clear user data and pending
                    }
                  });
              
                  return () => {
                    unsubscribe();
                  };
                }, []);
              
                return (
                  <div className="App">
                    <Switch>
                      ...
                    </Switch>
                  </div>
                );
              };
              
              const mapStateToProps = ({ user }) => ({
                currentUser: user.currentUser,
              });
              
              const mapDispatchToProps = {
                setAuthPending, // <-- wrap action creator in call to dispatch
                setCurrentUser,
              };
              
              const AuthRoute = props => {
                const { authPending, currentUser } = useSelector(state => state.user);
              
                if (authPending) {
                  return "Loading..."; // or maybe a loading spinner
                };
              
                return currentUser ? (
                  <Route {...props} />
                ) : (
                  <Redirect to="/login" />
                );
              };
              
              const AdminRoute = props => {
                const { authPending, currentUser } = useSelector(state => state.user);
              
                if (authPending) {
                  return "Loading..."; // or maybe a loading spinner
                };
              
                return checkUserAdmin(currentUser) ? (
                  <Route {...props} />
                ) : (
                  <Redirect to="/login" />
                );
              };
              
              <Switch>
                <Route
                  exact
                  path="/"
                  render={() => (
                    <MainLayout>
                      <Homepage />
                    </MainLayout>
                  )}
                />
                <Route
                  exact
                  path="/login"
                  render={() => (
                    <MainLayout>
                      <LoginPage />
                    </MainLayout>
                  )}
                />
                <AuthRoute
                  exact
                  path="/profile"
                  render={() => (
                    <MainLayout>
                      <ProfilePage />
                    </MainLayout>
                  )}
                />
                <AdminRoute
                  exact
                  path="/admin"
                  component={AdminHome}
                />
              </Switch>
              
              const userTypes = {
                SET_AUTH_PENDING: "SET_AUTH_PENDING",
                SET_CURRENT_USER: "SET_CURRENT_USER",
              };
              
              const setAuthPending = pending => ({
                type: userTypes.SET_AUTH_PENDING,
                payload: pending,
              });
              
              const INITIAL_STATE = {
                authPending: true,
                currentUser: null,
              };
              
              const userReducer = (state = INITIAL_STATE, action) => {
                switch (action.type) {
                  case userTypes.SET_CURRENT_USER:
                    return {
                      ...state,
                      authPending: false
                      currentUser: action.payload,
                    };
              
                  case userTypes.SET_AUTH_PENDING:
                    return {
                      ...state,
                      authPending: action.payload,
                    };
              
                  default:
                    return state;
                }
              };
              
              const App = (props) => {
                const {
                  setAuthPending, // <-- access action
                  setCurrentUser,
                  currentUser
                } = props;
              
                const admin = checkUserAdmin(currentUser);
                console.log(admin);
              
                useEffect(() => {
                  const unsubscribe = auth.onAuthStateChanged(async (userAuth) => {
                    setAuthPending(true); // <-- start auth pending
                    if (userAuth) {
                      const userRef = await handleUserProfile(userAuth);
                      userRef.onSnapshot((snapshot) => {
                        setCurrentUser({ // <-- will clear auth pending
                          id: snapshot.id,
                          ...snapshot.data(),
                        });
                      });
                    } else { 
                      setCurrentUser(null); // <-- clear user data and pending
                    }
                  });
              
                  return () => {
                    unsubscribe();
                  };
                }, []);
              
                return (
                  <div className="App">
                    <Switch>
                      ...
                    </Switch>
                  </div>
                );
              };
              
              const mapStateToProps = ({ user }) => ({
                currentUser: user.currentUser,
              });
              
              const mapDispatchToProps = {
                setAuthPending, // <-- wrap action creator in call to dispatch
                setCurrentUser,
              };
              
              const AuthRoute = props => {
                const { authPending, currentUser } = useSelector(state => state.user);
              
                if (authPending) {
                  return "Loading..."; // or maybe a loading spinner
                };
              
                return currentUser ? (
                  <Route {...props} />
                ) : (
                  <Redirect to="/login" />
                );
              };
              
              const AdminRoute = props => {
                const { authPending, currentUser } = useSelector(state => state.user);
              
                if (authPending) {
                  return "Loading..."; // or maybe a loading spinner
                };
              
                return checkUserAdmin(currentUser) ? (
                  <Route {...props} />
                ) : (
                  <Redirect to="/login" />
                );
              };
              
              <Switch>
                <Route
                  exact
                  path="/"
                  render={() => (
                    <MainLayout>
                      <Homepage />
                    </MainLayout>
                  )}
                />
                <Route
                  exact
                  path="/login"
                  render={() => (
                    <MainLayout>
                      <LoginPage />
                    </MainLayout>
                  )}
                />
                <AuthRoute
                  exact
                  path="/profile"
                  render={() => (
                    <MainLayout>
                      <ProfilePage />
                    </MainLayout>
                  )}
                />
                <AdminRoute
                  exact
                  path="/admin"
                  component={AdminHome}
                />
              </Switch>
              

              Community Discussions

              Trending Discussions on redux-logger
              • Cannot Read Property Show of Undefined When Using DocumentPicker.show() in React Native
              • Error: Node Sass does not yet support your current environment
              • React-native-async-storage doesn't recognize moment toDate() after killing app
              • java.lang.NoSuchMethodError: No virtual method setSkipClientToken(Z)V in class Lcom/facebook/GraphRequest;
              • Redux-Logger - 'reducer' is not defined
              • Error: Problem validating fields in app.json. Learn https://docs.expo.dev/workflow/configuration/ • Field: android.permissions[4] - should be string
              • Material ui TypeError: palette.theme undefined
              • Typing dispatch on a redux store correctly when using multiple middleware
              • Redux-Saga: TypeError: Cannot read properties of undefined (reading 'data')
              • React component won't update react-redux
              Trending Discussions on redux-logger

              QUESTION

              Cannot Read Property Show of Undefined When Using DocumentPicker.show() in React Native

              Asked 2022-Mar-22 at 18:08

              I followed some answers from here that are similar to my issues. But unfortunately, the error is not removed. That is why I asked here again.

              This is an old versioned React Native project where react-native-document-picker version was 2.1.0. When I upgraded the version to 8.0.0, the error shows as the following screenshot:

              documentpicker error

              The current files are as like below;

              android/settings.gradle

              ...    
              include ':react-native-document-picker'
              project(':react-native-document-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-document-picker/android')
              ...
              

              android/app/build.gradle

              dependencies {
                  implementation fileTree(dir: "libs", include: ["*.jar"])
                  ...
                  ...
                  implementation project(':react-native-document-picker')
              }
              

              package.json

              {
                "name": "awesomeproject",
                "version": "0.0.1",
                "private": true,
                "scripts": {
                  "android": "react-native run-android",
                  "ios": "react-native run-ios",
                  "start": "react-native start",
                  "test": "jest",
                  "lint": "eslint ."
                },
                "dependencies": {
                  "@react-native-community/datetimepicker": "^6.0.2",
                  "@react-navigation/drawer": "^6.3.1",
                  "@react-navigation/native": "^6.0.8",
                  "@react-navigation/stack": "^6.1.1",
                  "axios": "^0.26.1",
                  "moment": "^2.29.1",
                  "native-base": "^3.3.7",
                  "react": "17.0.2",
                  "react-native": "0.67.2",
                  "react-native-action-button": "^2.8.5",
                  "react-native-document-picker": "^8.0.0",
                  "react-native-dropdownalert": "^4.5.1",
                  "react-native-fcm": "^16.2.4",
                  "react-native-fetch-blob": "^0.10.8",
                  "react-native-fs": "^2.19.0",
                  "react-native-gesture-handler": "^2.3.2",
                  "react-native-image-picker": "^4.7.3",
                  "react-native-iphone-x-helper": "^1.3.1",
                  "react-native-keyboard-aware-scroll-view": "^0.9.5",
                  "react-native-keyboard-spacer": "^0.4.1",
                  "react-native-loading-spinner-overlay": "^3.0.0",
                  "react-native-modal-datetime-picker": "^13.1.0",
                  "react-native-modalbox": "^2.0.2",
                  "react-native-reanimated": "^2.4.1",
                  "react-native-safe-area-context": "^4.1.2",
                  "react-native-screens": "^3.13.0",
                  "react-native-simple-radio-button": "^2.7.4",
                  "react-native-simple-toast": "^1.1.3",
                  "react-native-svg": "^12.3.0",
                  "react-native-swiper": "^1.6.0",
                  "react-native-vector-icons": "^9.1.0",
                  "react-redux": "^7.2.6",
                  "redux": "^4.1.2",
                  "redux-logger": "^3.0.6",
                  "redux-saga": "^1.1.3"
                },
                "devDependencies": {
                  "@babel/core": "^7.12.9",
                  "@babel/runtime": "^7.12.5",
                  "@react-native-community/eslint-config": "^2.0.0",
                  "babel-jest": "^26.6.3",
                  "eslint": "7.14.0",
                  "jest": "^26.6.3",
                  "metro-react-native-babel-preset": "^0.66.2",
                  "react-test-renderer": "17.0.2"
                },
                "jest": {
                  "preset": "react-native"
                }
              }
              

              app.js

              import {DocumentPicker, DocumentPickerUtil} from 'react-native-document-picker';
              
                  pressOnAttach() {
                      Keyboard.dismiss();
                      this.refs.NoticeTitle.blur();
                      this.refs.NoticeDescription.blur();
                      setTimeout(() => {
                              DocumentPicker.show({
                              filetype: [DocumentPickerUtil.allFiles()],
                          }, (error, res) => {
                              if (error === null) {
                                  setTimeout(() => {
                                      if (!this.checkFileExtension(res.fileName)) {
                                          alert(AppText.VALID_EXTENSION_MESSAGE)
                                      } else {
                                          this.generateList(res.uri, res.fileName, res.fileSize);
                                      }
                                  }, 1000)
                              }
                          });
                      }, 1000)
                  }
              

              When I console.log the DocumentPicker and DocumentPickerUtil, it returns undefined always.

              Could anyone help me please to fix this issue? Thanks in advance!

              ANSWER

              Answered 2022-Mar-22 at 18:08

              The reason you are getting DocumentPicker undefined is the react-native-document-picker version 8.0.0 has been updated since version 2.1.0 which code you've posted.

              According to the library doc, you have to import the DocumentPicker differently. And the util DocumentPickerUtil is also not available to the updated version. For react-native-document-picker version 8.0.0 you have to import in the following way

              import DocumentPicker, { types } from 'react-native-document-picker';

              And also DocumentPicker.show method is no longer available you have to use the DocumentPicker.pick method.

              Ref:

              Source https://stackoverflow.com/questions/71575875

              Community Discussions, Code Snippets contain sources that include Stack Exchange Network

              Vulnerabilities

              No vulnerabilities reported

              Install redux-logger

              Typescript types are also available, via DefinitelyTyped:.

              Support

              For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

              DOWNLOAD this Library from

              Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
              over 430 million Knowledge Items
              Find more libraries
              Reuse Solution Kits and Libraries Curated by Popular Use Cases
              Explore Kits

              Save this library and start creating your kit

              Share this Page

              share link
              Reuse Pre-built Kits with redux-logger
              Consider Popular State Container Libraries
              Try Top Libraries by LogRocket
              Compare State Container Libraries with Highest Support
              Compare State Container Libraries with Highest Quality
              Compare State Container Libraries with Highest Security
              Compare State Container Libraries with Permissive License
              Compare State Container Libraries with Highest Reuse
              Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
              over 430 million Knowledge Items
              Find more libraries
              Reuse Solution Kits and Libraries Curated by Popular Use Cases
              Explore Kits

              Save this library and start creating your kit

              • © 2022 Open Weaver Inc.