Replace defaultProps with default parameters to avoid React 18 warning#194
Replace defaultProps with default parameters to avoid React 18 warning#194onepiecejigsaw wants to merge 4 commits intoMonte9:masterfrom
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( { |
|
@Monte9 can u merge this pr? |
When using
react-native-ratingswith 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