(This question is about understanding functionality, not asking for a step-by-step guide)
While using React Router, I noticed that Vscode IntelliSense can offer strongly-typed suggestions when I input parameters in a route like this:
<Route path='/users/:userId?' render={props => <UserManager selectedId={props.}/>} />
By typing props.match.params.
, any string entered in the path
attribute, such as :text
, becomes a strongly typed parameter accessible through the params property (and an optional parameter if followed by a question mark):
https://i.sstatic.net/Wj9cA.jpg
How does Vscode/TypeScript/React Router create a strong-typed variable from a plain user-inputted string?