报错:TypeError: null is not an object (evaluating 'Scene.props') 求排查方向
TypeError: null is not an object (evaluating 'Scene.props') in Your React Native App Hey there, let's break down why you're hitting this error and get your app running smoothly again. Looking at your code, there are a few key issues that could be causing this:
1. Incorrect Import of Your Scenes
In your scene.js, you're exporting the scenes as a default export:
export default scenes
But in AppContainer.js, you're trying to import it as a named export using destructuring:
import {scenes} from '../routes/home/scenes'
This will result in scenes being undefined (or null in some cases), which breaks the Router component since it's expecting a valid scene configuration. Fix this by changing the import to:
import scenes from '../routes/home/scenes'
2. Broken PropTypes Definition
Your AppContainer's propTypes setup is incorrect. The line store:PropTypes.checkPropTypes() doesn't do what you think it does—checkPropTypes is a function used to manually validate props, not to define the type of a prop.
Replace that with a valid prop type definition for your Redux store. For example:
static propTypes={ store: PropTypes.object.isRequired }
If you want to be more specific, you can use PropTypes.shape() to define the structure of your store, but object.isRequired is a safe starting point. This ensures your component receives a valid Redux store, which is critical for the Provider and Router to work correctly.
3. Possible react-native-router-flux Version Compatibility
If the above fixes don't resolve the error, check your react-native-router-flux version. The Actions.create() method you're using in scene.js has been deprecated in newer versions of the library.
Instead of wrapping your scenes with Actions.create, try directly exporting the JSX structure:
// scene.js import React from 'react'; import {Scene} from 'react-native-router-flux'; import HomeContainer from '../home/containers/HomeContainers'; export default ( <Scene key="root"> <Scene key="home" component={HomeContainer} title="home" initial/> </Scene> )
Then pass this directly to the Router's scenes prop as you already are.
Try applying these fixes one by one, starting with the import and PropTypes issues—those are the most likely culprits here.
内容的提问来源于stack exchange,提问作者Asics

