I am working on my project and i noticed that when strict mode is turned on it pushes two identical elements into my array. When the strict mode is off it pushes only one element into the array. Is there any explanation why this happens?
import {getRandomNumber} from './utils';
export function registerTicket() {
const newTicket = {
number: getRandomNumber(),
color: 'red',
}
this.setState((prevState) => {
prevState.tickets.push(newTicket);
return {
remainingTickets: --prevState.remainingTickets,
tickets: prevState.tickets,
}
})
}
Here is my state.
this.state = {
winningNumber: getRandomNumber(),
remainingTickets: 5,
tickets: [],
finished: false
};