Warning: Can't perform a React state update on an unmounted component. This is an no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous task in "a useEffect cleanup function".
My component is:
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { View, StyleSheet, Text } from 'react-native';
import { SvgUri } from 'react-native-svg';
import * as Colors from '../../config/colors';
import { STATIC_CONTENT_URL } from '../../config/apis';
export default function Categories({
category, active
}) {
useEffect(() => {
console.log('useEffect on Categories component');
return function cleanup() {
// cancel or unsubscribe
}
})
return (
<View style={{...styles.container, backgroundColor: active === category.id ? Colors.BG_PRIMARY_SHADE_ACTIVE : Colors.BG_WHITE}}>
<View style={styles.imgContainer}>
<SvgUri
width="100%"
height="100%"
uri={`${STATIC_CONTENT_URL}/static/assets/css/images/${category.img}.svg`}
/>
</View>
<Text style={styles.categoryName}>{category.name}</Text>
</View>
)
}
Categories.propTypes = {
category: PropTypes.object,
active: PropTypes.string
}
const styles = StyleSheet.create({
container: {
width: 90,
height: 90,
borderRadius: 4,
justifyContent: "center",
alignItems: "center",
marginTop: 10,
padding: 10,
},
imgContainer: {
width: 70,
height: 30,
paddingBottom: 2,
},
categoryName: {
fontSize: 9,
color: Colors.TEXT_COLOR_SOFT,
textAlign: "center",
}
})
Version:
"react-native": "0.61.5",
"react-native-svg": "^12.0.3"
All of svg files are static files and it load from the server & I don't want to import directly.