React Native component shows only one complaint instead of other more features
<p>I'm working on a screen that gets route parameters from the previous screen for navigation but it only shows the first complaint and not any other added complaints, I don't know what is causing this issue , the following is the code: </p>
<pre class="brush:php;toolbar:false;">const ECScreen = ({ route, navigation }) => {
const { imageUri, complaintDate, complaintId } = route.params;
const [complaints, setComplaints] = useState([]);
useEffect(() => {
if (imageUri && complaintDate) {
const newComplaint = {
id: complaints.length 1, // Assign next available ID
imageUri: imageUri,
date: complaintDate,
status: 'Pending',
};
setComplaints([...complaints, newComplaint]);
}
}, []);</pre>