Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: react quick start guide does not mention withRouter when passing history as prop #3553

Open
3 tasks done
DunhamGitHub opened this issue Mar 21, 2024 · 2 comments
Open
3 tasks done
Labels
content Issues related to the contents of the documentation website

Comments

@DunhamGitHub
Copy link

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

Trying to follow the simplest vanilla example (https://ionicframework.com/docs/react/quickstart), but getting an error:

image

Expected Behavior

No error in App.tsx when adding RouteComponentProps in Home.tsx

Steps to Reproduce

  1. Follow the vanilla tutorial :https://ionicframework.com/docs/react/quickstart
  2. Last step, before the error, is adding RouteComponentProps to const Home: React.FC = () => { so it becomes const Home: React.FC<RouteComponentProps> = () => { ...in Home.tsx (I am assuming all this is done in Home.tsx, the tutorial does not say...)
  3. Importing RouteComponents import { RouteComponentProps } from "react-router-dom"; (not documented in the tutorial)
  4. Switching to App.tsx show the error now (see "Current Behavior")

Code Reproduction URL

b

Ionic Info

Ionic:

   Ionic CLI       : 7.2.0 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework : @ionic/react 7.8.0

Capacitor:

   Capacitor CLI      : 5.7.3
   @capacitor/android : not installed
   @capacitor/core    : 5.7.3
   @capacitor/ios     : not installed

Utility:

   cordova-res : not installed globally
   native-run  : 2.0.1

System:

   NodeJS : v20.11.1 (/usr/local/Cellar/node@20/20.11.1/bin/node)
   npm    : 10.2.4
   OS     : macOS Unknown

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage New issues label Mar 21, 2024
@DunhamGitHub
Copy link
Author

importing withRouter from react-router
...and...
changing export default Home; to export default withRouter(Home); eliminated the error.
But is that the proper solution?

Screenshot 2024-03-21 at 16 59 12

@liamdebeasi
Copy link
Contributor

liamdebeasi commented Mar 25, 2024

Thanks! There looks to be some missing information in this quick start guide. The RouteComponentProps type is correct because the guide is trying to demonstrate how the history object can be passed as a property instead of having to call useHistory. However, withRouter is required in order to do this, but it's not mentioned on the guide. This is also confusing because it doesn't explicitly say to remove useHistory, so it's not entirely clear why it's showing both approaches.

I'm going to move this over to the docs repo so the team can work on clarifying this part of the guide.

@liamdebeasi liamdebeasi transferred this issue from ionic-team/ionic-framework Mar 25, 2024
@liamdebeasi liamdebeasi removed their assignment Mar 25, 2024
@liamdebeasi liamdebeasi added the content Issues related to the contents of the documentation website label Mar 25, 2024
@ionitron-bot ionitron-bot bot removed the triage New issues label Mar 25, 2024
@liamdebeasi liamdebeasi changed the title bug: <Home /> in Home.tsx (vanilla "Quickstart" example) | Type '{}' is missing the following properties from type 'RouteComponentProps<{}, StaticContext, unknown>': history, location, match bug: react Quickstart does not mention withRouter when passing history as prop Mar 25, 2024
@liamdebeasi liamdebeasi changed the title bug: react Quickstart does not mention withRouter when passing history as prop bug: react quick start guide does not mention withRouter when passing history as prop Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Issues related to the contents of the documentation website
Projects
None yet
Development

No branches or pull requests

2 participants