You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native集成Redux后出现TypeError与AppRegistry未注册报错求助

Troubleshooting Your React Native + Redux Startup Errors

Let's work through your issues step by step—first, the PropTypes error is almost certainly the root cause of the AppRegistry problem, since unhandled runtime errors can block your app from registering properly with React Native's AppRegistry.

1. Fix the _react.PropTypes.arrayOf TypeError

Even though you removed the prop-types dependency and your own code references, this error usually comes from one of two places:

  • Stale cache that's holding onto old code references
  • Outdated third-party dependencies that still try to import PropTypes from the core react package (React moved PropTypes to a separate prop-types package in v15.5, so old libraries might not be updated)

Here's how to fix it:

  • Clear all caches completely:
    Run these commands in your project root:
    # Reset React Native's metro bundler cache
    npx react-native start --reset-cache
    # Clear npm's global cache (use yarn cache clean if you use Yarn)
    npm cache clean --force
    
  • Update your Redux-related dependencies:
    Old versions of react-redux or related libraries might rely on the deprecated React PropTypes API. Upgrade them with:
    npm update react-redux redux redux-thunk
    # Or for Yarn:
    yarn upgrade react-redux redux redux-thunk
    
  • Double-check for hidden PropTypes references:
    Do a full project search (e.g., Ctrl+Shift+F in VS Code) for PropTypes or arrayOf—it's easy to miss a reference in a component or utility file that you forgot to update.

2. Fix the AppRegistry Error

This error is almost always a side effect of the earlier TypeError breaking your app's startup flow. Once you fix the PropTypes issue, this should resolve itself. But if it persists:

  • Verify your app name matches:
    Make sure the name value in app.json is exactly the same as the appName you're using in index.js (case-sensitive!).
  • Fix the missing RootStack import:
    In your Myapp.js, you're rendering <RootStack /> but there's no import statement for it! Add the correct import at the top of the file:
    import RootStack from './path/to/your/RootStack'; // Replace with your actual file path
    

3. Fix Your Redux Store Configuration (Prevent Future Issues)

Looking at your configureStore.js, there's a small mistake in how you're calling createStore—the order of arguments is wrong. The second parameter should be the initial state, and the third is the middleware enhancer. Your current code is passing middleware as the initial state, which is causing those weird @@redux/INIT logs. Correct it like this:

const configureStore = (initialState) => {
  const middleware = applyMiddleware(thunk, loggingMiddleware);
  // Correct order: rootReducer, initialState, enhancer(middleware)
  return createStore(rootReducer, initialState, middleware);
};

Give these steps a try, and your app should start up without those errors!

内容的提问来源于stack exchange,提问作者Ronak Amlani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 22:07:37