2017-12-26 17 views
0

私はReact Datepickerから現在の日付を無効にする方法を試みました。
ReactJsのReact Date Pickerで現在の日付(今日)を無効にするには?

以下は私のコードです。

<SingleDatePicker 
    showDefaultInputIcon 
    inputIconPosition={ICON_AFTER_POSITION} 
    date={input.value} 
    placeholder="Move Date" 
    numberOfMonths={input.numberOfMonths ? input.numberOfMonths : 1} 
    focused={meta.active} 
    openDirection="up" 
    onDateChange={value => { 
    const val = value && value.format ? value.format() : value; 
    input.onChange(val); 
    }} 
    onFocusChange={({ focused }) => { 
    if (focused) { 
     input.onFocus({ focused }); 
     return; 
    } 
    input.onBlur(); 
    }} 
/> 

誰かが助けてくれたら助けてください。

+0

範囲または1つの日付に基づいて無効にしていますか? – Anup

+0

http://airbnb.io/react-dates/?selectedKind=DRP%20-%20Day%20Props&selectedStory=with%20some%20blocked%20dates&full=0&down=1&left=1&panelRight=0&downPanel=storybook%2Factions%2Factions-panel check disウルのユースケースを解決するかもしれない – Anup

+0

はい@Anup私も過去の日を無効にする必要があります。だから私は解決策を行った。ご提案ありがとうございます。このリンク私は既に質問そのものに投稿しています。とりあえずありがとう –

答えて

0

今日は、isOutsideRange小冊子とmomentを使用して日付ピッカーから今日無効にすることができます。

以下は私の更新コードです。
明日の日付を最初に作成しました。

const tomo = moment().add(1, 'day').endOf('day'); 

明日以降の日付はisOutsideRangeです。

<SingleDatePicker 
    showDefaultInputIcon 
    inputIconPosition={ICON_AFTER_POSITION} 
    date={input.value} 
    placeholder="Move Date" 
    numberOfMonths={input.numberOfMonths ? input.numberOfMonths : 1} 
    focused={meta.active} 
    openDirection="up" 
    isOutsideRange={day => !isInclusivelyAfterDay(day, tomo)} 
    onDateChange={value => { 
    const val = value && value.format ? value.format() : value; 
    input.onChange(val); 
    }} 
    onFocusChange={({ focused }) => { 
    if (focused) { 
     input.onFocus({ focused }); 
     return; 
    } 
    input.onBlur(); 
    }} 
/> 
関連する問題