Socket
Socket
Sign inDemoInstall

rmc-tabs

Package Overview
Dependencies
4
Maintainers
4
Versions
58
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rmc-tabs

React Mobile Tabs Component(web & react-native)


Version published
Maintainers
4
Install size
2.66 MB
Created

Changelog

Source

1.2.29 / 2019-01-24

  • fix 修复 componentWillReceiveProps 时,page 使用 nextProps, tabs 使用 currentProps 导致逻辑逻辑判断出错

Readme

Source

rmc-tabs


React Mobile Tabs Component (web & react-native), inspired by react-native-scrollable-tab-view

NPM version react build status Test coverage gemnasium deps npm download

Screenshots

Development

npm i
npm start

Example

http://localhost:8000/examples/

online example: http://react-component.github.io/m-tabs/

install

rmc-tabs

docs

Usage

// normal
<Tabs tabs={[
    { key: 't1', title: 't1' },
    { key: 't2', title: 't2' },
    { key: 't3', title: 't3' },
    { key: 't4', title: 't4' },
    { key: 't5', title: 't5' },
]} initalPage={'t2'}
>
  <div key="t1"><p>content1</p></div>
  <div key="t2"><p>content2</p></div>
  <div key="t3"><p>content3</p></div>
  <div key="t4"><p>content4</p></div>
  <div key="t5"><p>content5</p></div>
</Tabs>

// single content
<Tabs tabs={[
    { title: 't1' },
    { title: 't2' },
    { title: 't3' },
    { title: 't4' },
    { title: 't5' },
]} onChange={(tab, index) => {
    this.setState({
        scData: JSON.stringify({ index: index + Math.random(), tab })
    });
}}
>
    <div>
        <p>single content</p>
        <p>{this.state.scData}</p>
    </div>
</Tabs>

// single content function
<Tabs tabs={[
    { title: 't1' },
    { title: 't2' },
    { title: 't3' },
    { title: 't4' },
    { title: 't5' },
]}
>
    {
        (index, tab) =>
            <div>
                <p>single content</p>
                <p>{JSON.stringify({ index: index + Math.random(), tab })}</p>
            </div>
    }
</Tabs>

// renderTabBar e.g: Sticky, react-sticky
./examples/sticky.tsx

react-native

npm run rn-init
npm run watch-tsc
react-native start
react-native run-ios

API

Tabs:

属性说明类型默认值必选
tabstabs dataModels.TabData[]true
tabBarPositionTabBar's position'top' | 'bottom' | 'left' | 'right'topfalse
renderTabBarrender for TabBar((props: TabBarPropsType) => React.ReactNode) | falsefalse
initialPageinitial Tab, index or keynumber | stringfalse
pagecurrent tab, index or keynumber | stringfalse
swipeablewhether to switch tabs with swipe gestrue in the contentbooleantruefalse
useOnPan (web only)use scroll follow panbooleantruefalse
prerenderingSiblingsNumberpre-render nearby # sibling, Infinity: render all the siblings, 0: render current pagenumber1false
animatedwhether to change tabs with animationbooleantruefalse
onChangecallback when tab is switched(tab: Models.TabData, index: number) => voidfalse
onTabClickon tab click(tab: Models.TabData, index: number) => voidfalse
destroyInactiveTabdestroy inactive tabbooleanfalsefalse
distanceToChangeTabdistance to change tab, width rationumber0.3false
usePageduse pagedbooleantruefalse
tabDirectiontab paging direction'horizontal' | 'vertical'horizontalfalse
tabBarUnderlineStyletabBar underline styleReact.CSSProperties | anyfalse
tabBarBackgroundColortabBar background colorstringfalse
tabBarActiveTextColortabBar active text colorstringfalse
tabBarInactiveTextColortabBar inactive text colorstringfalse
tabBarTextStyletabBar text styleReact.CSSProperties | anyfalse

TabBarPropsType (Common):

属性说明类型默认值必选
goToTabcall this function to switch tab(index: number) => voidtrue
tabstabs dataModels.TabData[]true
activeTabcurrent active tabnumbertrue
animateduse animatebooleantruetrue
renderTabrender the tab of tabbar(tab: Models.TabData) => React.ReactNodefalse
pagepage size of tabbar's tabnumber5false
onTabClickon tab click(tab: Models.TabData, index: number) => voidfalse
tabBarPositiontabBar's position defualt: top'top' | 'bottom' | 'left' | 'right'false
tabBarUnderlineStyletabBar underline styleReact.CSSProperties | anyfalse
tabBarBackgroundColortabBar background colorstringfalse
tabBarActiveTextColortabBar active text colorstringfalse
tabBarInactiveTextColortabBar inactive text colorstringfalse
tabBarTextStyletabBar text styleReact.CSSProperties | anyfalse

Test Case

npm test
npm run chrome-test

Coverage

npm run coverage

open coverage/ dir

License

rmc-tabs is released under the MIT license.

Keywords

FAQs

Last updated on 24 Jan 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc