2017-07-04 6 views
1

と反応デイ・ピッカーからDayPickerInputを使用することができません:私は以下のようにDayPickerInputインポートしようとするたびに活字体

import DayPickerInput from 'react-day-picker/DayPickerInput'; 

私はtsの警告が表示されます:「モジュールの宣言ファイルを見つけることができませんでした「反応日間-picker/DayPickerInput。 "唯一DayPickerが定義型を持っているようモジュールフォルダを見てみると

は、見えます。

私が代わりに以下のような必要メソッドを使用しよう:

var DayPickerInput = require('react-day-picker').DayPickerInput; 

私のプロジェクトでは、罰金のビルドが、コンポーネントが表示される必要があるとき、私は、コンソールでの2つのランタイムエラーを取得:

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. 

Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. 

DayPickerInputは、今の私のために使用不可能です。

+0

我々はそれに取り組んでいる:) https://github.com/gpbl/react-day-picker/issues/464 – gpbl

答えて

0

反応日ピッカーV6.2は、入力されたコンポーネントの活字体の定義を追加しました。問題が解決したかどうかを確認するためにアップグレードを試みてください。

+0

私はV6.2.1を持っており、これは私のためにまだ問題があります。 DayPickerInputのファイルはtypesフォルダにありますが、何らかの理由でtypescriptで取得されません。 – Jonathan

+0

は、ここで私が得ている問題のサンドボックスです:https://codesandbox.io/s/98o50qmn8y エラーががサンドボックスで間違っています。私が得ているエラーは、「モジュール「反応日ピッカー/ DayPickerInput」の宣言ファイルを見つけることができませんでした。上記のように。 あなたが動作しない、あなたが今持っているものの賛成で、それを拒否している、私は問題を解決するためのPRを行うに探してみましたが、私は他の誰かがすでにやった見ました。 – Jonathan

0

はバージョン7.0.7で、私は回避策としてglobals.d.tsにこれを追加する必要がありました:

declare module 'react-day-picker/DayPickerInput' { 
    import { DayPickerInput } from 'react-day-picker/types/DayPickerInput'; 
    export default DayPickerInput; 
} 

私の印象は、活字体の定義が最新ではないということである、と誰か(あなたや私?)それらを更新する必要がありますか? :)

関連する問題