-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace defaultProps with default parameters to avoid React 18 warning #194
base: master
Are you sure you want to change the base?
Conversation
#191 This issue is sorted by this PR |
Hi sorry to bother i tried both changes but still getting errors: import React, { useState, useEffect } from "react"; import { StyleSheet, Text, View, StyleProp, ViewStyle } from "react-native"; import Star from "./components/Star"; export type TapRatingProps = { /**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
/**
// const TapRating: React.FunctionComponent = props => { const TapRating: React.FunctionComponent = useEffect( () => {
// }, [props.defaultRating] ); const renderStars = rating_array => { const starSelectedInPosition = position => {
}; // const { count, reviews, showRating, reviewColor, reviewSize } = props; if ( props.starContainerStyle ) { const ratingContainerStyle = [styles.ratingContainer]; if ( props.ratingContainerStyle ) { _.times( count, index => { return ( // TapRating.defaultProps = { const styles = StyleSheet.create( { export default TapRating; `import React, { useState } from "react"; const STAR_IMAGE = require( "../images/airbnb-star.png" ); export type StarProps = { // const Star: React.FunctionComponent = props => { const spring = () => {
}; const { const starSource = return ( // Star.defaultProps = { export default Star; const styles = StyleSheet.create( { |
When using
react-native-ratings
with React 18, the following warning appears:"Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead."
This set of changes removes the usage of
defaultProps
, and replaces it with default parameters, avoiding the warning and protecting against future releases of React removing support fordefaultProps