Answer the question
In order to leave comments, you need to log in
How to fix Uncaught Error: Objects are not valid as a React child?
There is the following code:
const initialState = {
startDate: null,
endDate: null,
focusedInput: null,
}
function reducer(state, action) {
switch (action.type) {
case 'focusChange':
return {...state, focusedInput: action.payload}
case 'dateChange':
return action.payload
default:
throw new Error()
}
}
function DateTimePicker1() {
const [state, dispatch] = useReducer(reducer, initialState)
return (
<div>
<DateRangeInput
onDatesChange={data => dispatch({type: 'dateChange', payload: data})}
onFocusChange={focusedInput => dispatch({type: 'focusChange', payload: focusedInput})}
startDate={state.startDate} // Date or null
endDate={state.endDate} // Date or null
focusedInput={state.focusedInput} // START_DATE, END_DATE or null
/>
<h1>endDate={state.endDate}</h1>
</div>
)
}
export default DateTimePicker1;
<h1>endDate={state.endDate}</h1>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question