Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pankod/react-native-store-rating

Package Overview
Dependencies
Maintainers
8
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pankod/react-native-store-rating

React Native store rating like Airbnb

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2K
increased by74.57%
Maintainers
8
Weekly downloads
 
Created
Source
            

React Native Store Rating

React Native Module to getting users to easily rate and leave a review about your app.

npm version dependencies Status dev-dependencies Status

Created by Pankod


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 StoreGoogle 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


PropertiesTypeDescriptionDefault
playStoreUrl
*required
stringGoogle Play Store App Url
market://details?id=${APP_PACKAGE_NAME}
iTunesStoreUrl
*required
stringApple ITunes App Url
itms-apps://itunes.apple.com/app/${APP_ID}
modalTitlestringThe modal header title"How many stars do you give to this app?"
rateBtnTextstringThe button text."Rate"
cancelBtnTextstringThe cancel button text."Cancel"
totalStarCountnumberThe starts count on modal.5
defaulRatingnumberIf no number set, it will determine 3 stars rating.5
isVisiblebooleanShows rating on modal. true
sendBtnTextstringThe text of send button."Send"
commentPlaceholderTextstringUser review modal placeholder text."You can write your comments here"
isTransparentbooleanBackground styletrue
starLabelsarrayThe array of rating title.['Terrible', 'Bad', 'Okay', 'Good', 'Great']
emptyCommentErrorMessagestringUser review comment box validation text"Please specify your opinion."
isModalOpenbooleanControl if the modal open or not.false
storeRedirectThresholdnumber?3
style
*deprecated
ObjectAn object containing the styles objects to style the modal. Use styles instead.example:
{ backgroundColor: #000, paddingHorizontal: 30 }
stylesObjectAn 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.{}
ratingComponentReact.ElementTypeYour custom rating component.react-native-ratings/AirbnbRating
ratingPropsObjectNecessary 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.{}
modalPropsObjectProps to pass to the React Native's Modal component.{}

Functions


PropertiesTypeDescriptionDefault
onStarSelectedFunctionFunction fired when the rating has changed.return: number
onClosed
*required
FunctionFunction fired when the modal has closed.console.warn('pressed cancel button...')
onSendReviewFunctionFunction fired when redirected to the store. Passes the component state.
sendContactUsForm
*required
FunctionRead 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.

Keywords

FAQs

Package last updated on 10 Jun 2021

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc