Render global footer in react-native-router-flux 3.x

情到浓时终转凉″ 提交于 2019-12-12 01:39:43

问题


I have an app where on all scenes I want to render a global navigation footer at the bottom of the screen. This was a very easy thing to do in RNRF 2.x with the footer prop, but I'm having quite a lot of trouble implementing it in 3.x since the footer prop does not exist anymore. Anyone know how to go about doing this?


回答1:


You can do this with only React Native. Just wrap your old main component in a new View that contains the old main component and the footer. Then the footer will always be shown.

Assuming you have a main component named MainComponent in a file path/to/main/component.js:

// path/to/main/component.js
export default class MainComponent extends React.Component {
    ...
}

Just change it to this:

// path/to/main/component.js
class MainComponent extends React.Component {
    ...
}

export default () => (
    <View styles={styles.newMainComponent}>
        <MainComponent />
        <GlobalFooter />
    </View>
);

You may need to move some styles from your old main component to the new view that wraps it.



来源:https://stackoverflow.com/questions/42393552/render-global-footer-in-react-native-router-flux-3-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!