17
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

useHistory が使えない時

Posted at

react-route の v6 からは、useHistory ではなくて useNavigate が推奨になりました。
使い方は、下記です。

useNavigation

index.jsx
import {useNavigate} from "react-router-dom"

const navigation = useNavigate()

/* ページ遷移は下記を使う */
navigation("/hoge") /* /hoge に遷移 */

/* history.goBack()は、 */
navigation(-1)

react-route、v6 から変更が多くて、昔のコードが使えないことが多い (から への変更など) 。

17
1
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
17
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?