0

I want to add header and footer in all pages like below.

Example : enter image description here

Then how render header and footer in other components ?

That means write code once then how render it in various pages?

Saravana Kumar
  • 3,230
  • 7
  • 26
  • 44

2 Answers2

0

Using react-native-router-flux makes what you aim for pretty easy if I got your question right. Check out the documentation https://github.com/aksonov/react-native-router-flux

0

i never try that react-native-router-flux, but when i see the docs, maybe you can do something like this:

import React, { Component } from 'react';
import { Router, Scene } from 'react-native-router-flux';

import PageOne from './PageOne';
import PageTwo from './PageTwo';

export default class App extends Component {
  render() {
    return (
      <View style={{ flex:1 }}>
        <YourHeaderComponent />
        <Router>
          <Scene key="root">
            <Scene key="pageOne" component={PageOne} title="PageOne" initial={true} />
            <Scene key="pageTwo" component={PageTwo} title="PageTwo" />
          </Scene>
        </Router>
        <YourFooterComponent />
      </View>
    )
  }
}

You can wrap the Router with View which its sibling is your header and footer component.

I Putu Yoga Permana
  • 3,980
  • 29
  • 33