0.3.0 • Published 6 years ago

route-nav-tabs v0.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

route-nav-tabs

A react component of swipeable nav tabs. It is composed with react-swipeable-views and react-router.

Demo

demo

Usage

run npm i route-nav-tabs react-router-dom --save

import React from 'react';
import ReactDOM from 'react-dom';
import { HashRouter as Router } from 'react-router-dom';
import { RouteInTheTabContents, Tab, Content } from 'route-nav-tabs';

// example of content components
import Foo from './Foo';
import Bar from './Bar';

const App = () => (
  <Router>
    <RouteInTheTabContents
        basePath=""
        className={{
          wrap: 'nav-tabs', 
          contentWrap: 'contents',
          content: 'content'
        }}
      >
        <Tab pathname="foo" desc="foo's tab" />
        <Tab pathname="bar" desc="bar's tab" />

        {/* Content will receive and pass Route's render methods (component/render/children). */}
        <Content pathname="foo" className="content-foo" component={Foo} />
        <Content pathname="bar" className="content-bar" render={props=><Bar {...props}/> unmountWhenNotMatch={true}} />
        
      </RouteInTheTabContents>
  </Router>
);
ReactDOM.render(<App />, document.getElementById('root'));

when navigate to localhost:3000/#/foo, Foo component will render.

when swipe or tap the tabs from foo to bar, Foo will unmount and Bar will render.

API

Content

propstypedefaultdescription
unmountWhenNotMatchbooleanfalsewhen tab switches, whether to umount previous tab's component. Only work when using component or render as Route's render function . This prop will ignore if using children to render.
onRenderfunctionnoopcallback when route change and match.
0.3.0

6 years ago

0.2.0

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago