I am using react functional component with react router v5 . I am using useParam function to fetch a param. How can I set default value of the param when it is not available or undefined.
My router code
<Switch>
    // ....
    // .... 
    <Route path="/users/:userId?" component={UserInfo} />
    // ....
</Switch>
My component code
export const UserInfo = (props) => {
    const {userId} = useParams()
    // ... other codes 
}
I am getting undefined when calling http://localhost:3000/users/.
Any idea will be helpful.
 
     
    