Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7186

React crashes without displaying error when user selects one option but then changes it to another option

$
0
0

My code is working when a user selects any of the options.

However, when they select the 'now' option and then change their mind and select the 'specific' option, React crashes without displaying an error - it just shows a white screen.

This problem doesn't occur when the options are selected the other way round - when 'specific' is selected and the user changes their mind and selects 'now'.

When 'specific' is selected a new input is rendered.

A simplified version of the code is below:

render() {let startSelling = values.tickets.map((e,i) => {    if(e.startSelling == 'specific'){        return(<div>                 <DatePicker                        className="datePicker"                        timeIntervals={15}                        onChange={event => this.props.setSpecificTime(event, i, 'startSellingTime', values)}                        selected={values.tickets[i].startSellingTime}                        placeholderText='Select Date And Time'                        showTimeSelect                        dateFormat="Pp"                        /></div>        )    }else{return <div></div>}})return (<>        {this.state.tickets.map((e, i) => {            return (<div><div>       <select                        value={values.tickets[i].startSelling}                        onChange={event => this.props.changeSellingTimes(event, i, 'startSelling', 'startSellingTime', values)}><option value='' disabled>Start Selling Tickets</option><option value="now">Now</option><option value="specific">Specific Date and Time</option>                        {i===1 ? <option value="whenPreviousSoldOut">When {values.tickets[0].ticketType} Is Sold Out</option>:<option value="whenPreviousSoldOut" disabled={i==0}>When A Previous Ticket Is Sold Out</option>}  </select></div>                {startSelling[i]}</div>            )        })}</>)

}

Where am I going wrong?


Viewing all articles
Browse latest Browse all 7186

Trending Articles