npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pankod/react-native-store-rating

v1.2.0

Published

React Native store rating like Airbnb

Downloads

630

Readme

npm version dependencies Status dev-dependencies Status

Ratings and reviews influence how your app ranks in search results, and can affect whether someone downloads your app. Users can rate your app on a scale of desired amount of stars. They can also add a written review for iOS and Android apps.

Stores Supported:

| Apple App Store | Google Play |
:--------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | | | | | | |

Getting started

$ npm install react-native-store-rating --save

or

$ yarn add react-native-store-rating

Usage

Users are presented with a modal allowing them to choose amount of stars which is defined with totalStarCount props.

The star rate taken from the users is compared to the value defined in "storeRedirectThreshold". If this value is greater than the value of "storeRedirectThreshold", the user is directed to the App store or Google Play Store. If it is equal and smaller, comment popup will be opened and users will be allowed to type comment.

Example: Let's say we defined 3 as a value to storeRedirectThreshold property,

<RateModal
	storeRedirectThreshold={3}
	// ... props
/>

User redirect to App Store or Google Play Store when the given star rate is greater then 3.

Comment modal will be opened if the given star rate equal or less then 3.

Live Demo with Expo

Explore with Expo Snack

Example

import React, { Component } from 'react'
import { Text, View, StyleSheet, TouchableOpacity } from 'react-native'
import RateModal from 'react-native-store-rating'

export default class example extends Component {
	state = {
		isModalOpen: false
	}

	const styles = StyleSheet.create({
		container: {
			flex: 1,
			justifyContent: 'center',
			alignItems: 'center'
		}
	})

	const rateModalStyles = StyleSheet.create({
	    button: {
	      backgroundColor: 'transparent',
	      borderColor: 'transparent',
	      textTransform: 'upparcase'
	    },
	})

	render() {
		return (
			<View style={styles.container}>
				<TouchableOpacity onPress={() => this.setState({ isModalOpen: true })}>
				<Text> Open Modal </Text>
			</TouchableOpacity>

			<RateModal
			    modalTitle="Your modal title"
				rateBtnText={'Rate'}
				cancelBtnText={'Cancel'}
				totalStarCount={5}
				defaultStars={5}
				isVisible={true}
				sendBtnText={'Send'}
				commentPlaceholderText={'Placeholder text'}
				emptyCommentErrorMessage={'Empty comment error message'}
				iTunesStoreUrl={'itms-apps://itunes.apple.com/app/${APP_ID}'}
				isModalOpen={this.state.isModalOpen}
				storeRedirectThreshold={3}
				style={{
					paddingHorizontal: 30,
				}}
				onStarSelected={(e) => {
					console.log('change rating', e);
				}}
				onClosed={() => {
					console.log('pressed cancel button...')
						this.setState({
						isModalOpen: false
					})
				}}
				sendContactUsForm={(state) => {
					alert(JSON.stringify(state));
				}}
				styles={rateModalStyles}
		        ratingProps={{
		            selectedColor: 'red',
		        }}
		        modalProps={{
		            animationType: 'fade',
		        }}
			/>

			</View >
		)
	}
}

Options

| Properties | Type | Description |Default | |------------|-------------------------------------|-------------|----------------------------------------------------------------| | playStoreUrl *required | string | Google Play Store App Url market://details?id=${APP_PACKAGE_NAME} | | | iTunesStoreUrl *required | string | Apple ITunes App Url itms-apps://itunes.apple.com/app/${APP_ID}| | | modalTitle | string | The modal header title | "How many stars do you give to this app?" | | rateBtnText | string | The button text. | "Rate" | | cancelBtnText | string | The cancel button text. | "Cancel" | | totalStarCount | number | The starts count on modal. | 5 | | defaulRating | number | If no number set, it will determine 3 stars rating. | 5 | | isVisible | boolean | Shows rating on modal. | true | | sendBtnText | string | The text of send button. | "Send" |
| commentPlaceholderText | string | User review modal placeholder text. | "You can write your comments here" | | isTransparent |boolean | Background style | true | | starLabels | array | The array of rating title. | ['Terrible', 'Bad', 'Okay', 'Good', 'Great'] | | emptyCommentErrorMessage | string | User review comment box validation text | "Please specify your opinion." | | isModalOpen | boolean | Control if the modal open or not. | false | | storeRedirectThreshold | number | ? | 3 | | style *deprecated | Object | An object containing the styles objects to style the modal. Use styles instead. | example:{ backgroundColor: #000, paddingHorizontal: 30 } | | styles | Object | An object for the styles for all the components inside RateModal (modal, title, buttons, textbox, error message). It overrides the default styling at Assets/Styles/Ratemodal.tsx, use the same properties for selectors as there. | {} | | ratingComponent | React.ElementType | Your custom rating component. | react-native-ratings/AirbnbRating | | ratingProps | Object | Necessary props for the rating component not mentioned above. Depends on the component you use, but here you can set the color of the stars for the AirbnbRating as well. | {} | | modalProps | Object | Props to pass to the React Native's Modal component. | {} |

Functions

| Properties | Type | Description |Default | |------------|-------------------------------------|-------------|----------------------------------------------------------------| | onStarSelected | Function | Function fired when the rating has changed.| return: number | | onClosed *required | Function | Function fired when the modal has closed.| console.warn('pressed cancel button...') | | onSendReview | Function | Function fired when redirected to the store. Passes the component state. | | | sendContactUsForm *required | Function | Read component state and function fired when the user comment was submitted. | { isModalOpen: true, rating: 3, review: "Lorem ipsum dolor sit amet...", reviewError:false, showContactForm:true } |

Notes

As of version 1.1.0 this package is compatible with both iOS and Android.

Releases

  • 1.0.0 - Initial release
  • 1.1.0 - Some props and functions name changed && added example app.