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]: type defs on NavLink broken, Property 'children' is missing in type but required in type 'NavLinkProps'. #8719

Closed
rtmann opened this issue Mar 15, 2022 · 3 comments
Labels

Comments

@rtmann
Copy link
Contributor

rtmann commented Mar 15, 2022

What version of React Router are you using?

6.2.2

Steps to Reproduce

  • Install react router and react router-dom 6.2.2 in a typescript project
  • Try to use a <NavLink from react router dom without any children.

Typescript expects NavLink to have an attribute called children set and is required. React expects children attributes to be passed as child nodes. The attribute isn't optional and can't be omitted without TS errors.

Expected Behavior

<NavLink to={'somelink'} />

Should work without any children or specifying a children attribute.

Actual Behavior

Error in typescript:

Property 'children' is missing in type '{ to: string; className: string; }' but required in type 'NavLinkProps'

@rtmann rtmann added the bug label Mar 15, 2022
@MichaelDimmitt
Copy link

reading up on this adding a few links as I go
#8164

@timdorr
Copy link
Member

timdorr commented Mar 17, 2022

Should be as simple as making this optional:

Can you submit a PR?

@rtmann
Copy link
Contributor Author

rtmann commented Mar 17, 2022

Can you submit a PR?

Done: #8725

It says I need a maintainer. Added my name to contributors (signed the agreement).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants