0.0.2 • Published 5 years ago

react-native-noticebar-ts v0.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

react-native-noticebar-ts

react-native竖向滚动通知栏(公告栏)

install 使用

$ npm i react-native-noticebar-ts
$ yarn add react-native-noticebar-ts

Usage

import NoticeBar from 'react-native-noticebar-ts'

class Demo extends Component<props, state> {
  constructor(props) {
    super(props)
    this.state = {
      noticeList: [
        {
          id: 1,
          title: 'This is Notice Bar!'
        },
        {
          id: 2,
          title: 'Notice Bar coming!!'
        }
      ]
    }
  }

  // noticebar change event
  handleChange = (index) => {
    console.log(`Current index is ${index}.` )
  }

  // render item
  renderBarItem = (item:any, index:number) => {
    return (
      <View>
        <Text numberOfLines={1}>{item.title}</Text>
      </View>
    )
  }

  render() {
    return (
      <View>
        <Text>NoticeBar Demo</Text>
        <NoticesBar
          data={noticeList}
          delay={3000}
          duration={500}
          scrollHeight={28}
          onChange={this.handleChange.bind(this)}
          renderItem={this.renderBarItem.bind(this)}
        />
      </View>
    )
  }
}

Props

如果问题请联系 fwf1024@163.com