0

Completely new to React, so please forgive my ignorance.

Using ReactStrap for this example. I'm attempting to define {url} dynamically, to where it's defined under src/components in its own jsx file:

const NavLink = ({ url },{ children }) => (
  <RSNavLink href={url}>
    {children}
  </RSNavLink>
);

but when I call the component elsewhere, I can insert whatever hyperlink I'd like:

<NavLink href="/">Hello, World!</NavLink>

I'm not able to find documentation specific to what I'm looking for (or at least, I may not be searching for the right thing). If anyone could point me in the right direction, it'd be much appreciated.

0

1 Answer 1

2

In NavLink Component you are wrongly destructing props value and give exactly same name as props. change it like this

const NavLink = ({ url ,children }) => (
  <RSNavLink href={url}>
    {children}
  </RSNavLink>
);

 <NavLink url="#">
     Hello World
 </NavLink>

check demo in stackblitz

Sign up to request clarification or add additional context in comments.

1 Comment

That was exactly it. Thanks so much, I really appreciate it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.