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

React Native打车App报错:undefined is not an object(evaluating '_react2.Proptypes.store')

Fixing "undefined is not an object(evaluating '_react2.Proptypes.store')" in Your Taxi Booking App

Hey there, let's break down the error you're hitting and get your app back on track. That error points directly to an issue with how you're using PropTypes in your AppContainer component. Here's what's going wrong and how to fix it:

Root Cause

Starting with React 16, the PropTypes utility was removed from the core React library. You've already installed the standalone prop-types package (I see it listed in your package.json), but your code is still trying to pull PropTypes from the react import—this means PropTypes ends up being undefined when you try to use PropTypes.object.isRequired, hence the error.

Step-by-Step Fix

1. Correct the PropTypes Import

Update your AppContainer component to import PropTypes from the standalone package instead of React:

import React, { Component } from "react";
import PropTypes from 'prop-types'; // Add this line, remove PropTypes from React import
import { Router } from "react-native-router-flux";
import scenes from "../routes/scenes";
import { Provider } from "react-redux";

export default class AppContainer extends Component{
  static propTypes = {
    store: PropTypes.object.isRequired
  }
  render(){
    return(
      <Provider store = {this.props.store}>
        <Router scenes = {scenes} />
      </Provider>
    )
  }
}

2. Double-Check Store Propagation

While the PropTypes fix should resolve the immediate error, make sure you're correctly passing the Redux store to AppContainer in your root component. For example:

// Example root component setup
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from './path/to/rootReducer'; // Your combined reducers
import AppContainer from './path/to/AppContainer';

// Create your store with middleware
const store = createStore(rootReducer, applyMiddleware(thunk));

// Render AppContainer with the store prop
export default function Root() {
  return <AppContainer store={store} />;
}

3. Verify Dependency Compatibility

Your react-native-router-flux version (4.0.0-beta.24) is a bit outdated, but it should work with React 16 and React Native 0.51. If you hit other issues after fixing PropTypes, you might consider updating it to a more stable release—but let's tackle the current error first.

Final Notes

After making these changes, rebuild your app (clear the Metro bundler cache if needed with react-native start --reset-cache) and test again. The PropTypes import fix is the critical one here—once that's sorted, the store prop validation should work as expected, and the error should disappear.

内容的提问来源于stack exchange,提问作者Prashant Chaulagain

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 06:47:26