1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【react-router-dom】Linkコンポーネントのtoにオブジェクトでstateプロパティを渡せない

1
Posted at

はじめに

  • react-router-domの話

問題

  • 渡してもconsole.logした時のstateに入らないしそもそもIDE上でエラーになってる

解決

  • Linkコンポーネントのtoの中ではなく、stateというプロップスを渡せるようになっていたので、そちらに渡して解決

終わりに

解決に向かう過程で、IDEでエラーが出ていたので、LinkコンポーネントのtoからWebstormでコードジャンプして、toの中身さらにジャンプすると確かにstateが渡せなさそうだった。

じゃあstateはどこに定義されている?ということでコード追い方わからず、公式ドキュメントを見て↓を確認できた。stateプロップスに入れて解決。

ちゃんとコード読みたいなと思い、コードジャンプして再度見直すと、toと並列にstateがあったのでここで解決もできたのだろうなと思う。

そもそも今はコードジャンプに頼って、なんとなくそれっぽいでコードを書いて静的解析通してみないとわからないので、tsの型定義ファイルを自分で読めるようにしていきたい。
バックエンドの開発でもossの中身が読める周りの人は開発速度が段違いなので。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?