天天看點

TypeError: (0 , _reactNavigation.addNavigationHelpers) is not a function

TypeError: (0 , _reactNavigation.addNavigationHelpers) is not a function

React Navigation将這個方法移除了

新的案例連結

新的redux內建方法如下:

1.将

createAppContainer建立的

元件,包裝在

Provider中

let RootStack = createStackNavigator({
  Counter: CounterContainer,
  StaticCounter: StaticCounterContainer,
});

let Navigation = createAppContainer(RootStack);

// Render the app container component with the provider around it
export default class App extends React.Component {
  render() {
    return (
      <Provider store={store}>
        <Navigation />
      </Provider>
    );
  }
}
           

2.在需要使用rudex狀态的元件中這樣寫:注意不要使用@修飾符。

import { Provider, connect } from 'react-redux';

...


class StaticCounter extends React.Component {
  static navigationOptions = {
    title: `Same number, wow!`,
  };

  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.paragraph}>{this.props.count}</Text>
      </View>
    );
  }
}

// Connect the screens to Redux
let CounterContainer = connect(state => ({ count: state.count }))(Counter);
           

配合使用dva-core體驗還是不錯的