Giter Club home page Giter Club logo

react-native-noticebar's Introduction

react-native-noticebar

NoticeBar component for React Native, works at iOS and Android.

Install

npm install react-native-noticebar --save

Usage

import NoticeBar from 'react-native-noticebar'

class Demo extends React.Component {
  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}.` )
  }

  // noticebar press event
  handlePress = (item) => {
    console.log(item)
  }

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

  render() {
    return (
      <View>
        <Text>NoticeBar Demo</Text>
        <NoticeBar
          data={ noticeList }
          renderBarItem={ this.renderBarItem }
          scrollHeight={ 40 }
          scrollBarStyle={ styles.barStyle }
          delay={ 3000 }
          duration={ 500 }
          easing='linear'
          onChange={ this.handleChange }
          onPress={ this.handlePress }></NoticeBar>
      </View>
    )
  }
}

Props

Prop name Description Type Default
data You know, the data PropTypes.string or PropTypes.element
scrollHeight Height of the single Bar PropTypes.number 36
renderBarItem PropTypes.func
scrollBarStyle Bar wrap's style PropTypes.object
delay PropTypes.number 3000
duration PropTypes.number 500
easing PropTypes.string, One of the ['step0','step1','linear','ease','quad','cubic','sin','circle','exp', 'bounce'] linear
onChange Callback when noticebar has changed PropTypes.func
onPress Press function PropTypes.func

react-native-noticebar's People

Contributors

seymoe avatar

Stargazers

 avatar  avatar

react-native-noticebar's Issues

移除日志打印

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-noticebar/src/NoticeBar.js b/node_modules/react-native-noticebar/src/NoticeBar.js
index 318529b..71fdd56 100644
--- a/node_modules/react-native-noticebar/src/NoticeBar.js
+++ b/node_modules/react-native-noticebar/src/NoticeBar.js
@@ -57,8 +57,8 @@ export default class NoticeBar extends Component {
     }
   }
 
-  componentWillReceiveProps(nextProps) {
-    console.log('componentWillReceiveProps', nextProps.data)
+  UNSAFE_componentWillReceiveProps(nextProps) {
+    // console.log('componentWillReceiveProps', nextProps.data)
     this.setState({
       enableAnimation: nextProps.enableAnimation ? true : false
     }, () => {
@@ -143,7 +143,7 @@ export default class NoticeBar extends Component {
           isInteraction: false,
           toValue: { x: 0, y: this.state.kb_tempValue },
           duration: this.state.duration, // 动画持续的时间(单位是毫秒),默认为500
-          easing: easingWay
+          easing: easingWay,
         }
       ),
     ])

This issue body was partially generated by patch-package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.