MCPcopy Index your code
hub / github.com/react-dates/react-dates / componentWillReceiveProps

Method componentWillReceiveProps

src/components/DayPicker.jsx:284–361  ·  view source on GitHub ↗
(nextProps, nextState)

Source from the content-addressed store, hash-verified

282 }
283
284 componentWillReceiveProps(nextProps, nextState) {
285 const {
286 hidden,
287 isFocused,
288 showKeyboardShortcuts,
289 onBlur,
290 orientation,
291 renderMonthText,
292 horizontalMonthPadding,
293 } = nextProps;
294 const { currentMonth } = this.state;
295 const { currentMonth: nextCurrentMonth } = nextState;
296
297 if (!hidden) {
298 if (!this.hasSetInitialVisibleMonth) {
299 this.hasSetInitialVisibleMonth = true;
300 this.setState({
301 currentMonth: nextProps.initialVisibleMonth(),
302 });
303 }
304 }
305
306 const {
307 daySize,
308 isFocused: prevIsFocused,
309 renderMonthText: prevRenderMonthText,
310 } = this.props;
311
312 if (nextProps.daySize !== daySize) {
313 this.setState({
314 calendarMonthWidth: getCalendarMonthWidth(
315 nextProps.daySize,
316 horizontalMonthPadding,
317 ),
318 });
319 }
320
321 if (isFocused !== prevIsFocused) {
322 if (isFocused) {
323 const focusedDate = this.getFocusedDay(currentMonth);
324
325 let { onKeyboardShortcutsPanelClose } = this.state;
326 if (nextProps.showKeyboardShortcuts) {
327 // the ? shortcut came from the input and we should return input there once it is close
328 onKeyboardShortcutsPanelClose = onBlur;
329 }
330
331 this.setState({
332 showKeyboardShortcuts,
333 onKeyboardShortcutsPanelClose,
334 focusedDate,
335 withMouseInteractions: false,
336 });
337 } else {
338 this.setState({ focusedDate: null });
339 }
340 }
341

Callers

nothing calls this directly

Calls 3

getFocusedDayMethod · 0.95
getCalendarMonthWidthFunction · 0.85
isSameMonthFunction · 0.85

Tested by

no test coverage detected