Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

react-native-user-score

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-user-score

A lightweight, flexible user score component

latest
Source
npmnpm
Version
1.0.5
Version published
Weekly downloads
6
200%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-user-score

A flexible, lightweight user score component. The component responds to drags and not just clicks, icon boundaries are computed automatically.

Installation

npm i -S react-native-user-score

or

yarn add react-native-user-score

Usage

import React, { Component } from 'react';

import { View, ScrollView, Text } from 'react-native';

import ScoreView from 'react-native-score-rating';

export class Demo extends Component<*,*> {
  state = {
    value: 2,
    scrollEnabled: true,
  };

  render() {
    return (
      <View
        style={{
          flex: 1,
          justifyContent: 'center',
        }}
      >
        <ScrollView scrollEnabled={this.state.scrollEnabled}>
          <ScoreView
            value={this.state.value}
            maximum={5}
            onChangeValue={value =>
              this.setState({ scrollEnabled: false, value })
            }
            onChangeFinish={() => this.setState({ scrollEnabled: true })}
            renderItem={active => (
              <Text color={active ? Colors.yellow20 : Colors.dark20} icon>
                {Icons.star}
              </Text>
            )}
          />
        </ScrollView>
      </View>
    );
  }
}

Note: Text is a custom component to demonstrate coloring. You have absolute control in the icon rendered -- styling included.

Props

NameDescriptionDefault
valueCurrent score0
maximumMaximum score5
spacingSpacing between each component*10
onChangeValueFunc:bool=>JSX to render a single score componentNot supplied - requires implementation
onChangeFinishFunc:() => void for triggering event after score is finaly changedNot supplied - requires implementation

* Spacing is applied as a right margin of all inner scores.

License

The MIT License.

Keywords

react

FAQs

Package last updated on 09 Feb 2018

Did you know?

Socket

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