Is there a way to pass props with a dynamic index like link{1}, link{2}, etc?

I am trying to create a component that for now accepts 2 groups of inputs + labels.

import React from 'react'
import MyLogic from './MyLogic';

interface MyProps {
    url1: string
    text1: string   
    url2: string
    text2: string   
}

const MyLogic: React.FC<MyProps> = props => {

    const { url1, text1, url2, text2 } = props;

    return (
       <>
          <MyLogic {...{ url: url1, text: text1 }} />
          <MyLogic {...{ url: url2, text: text2 }} />
       </>
    )

}

export default MyLogic;

Get it?

I need to handle the props dynamically because at some point there could 100 inputs and every input needs an index, where the first input needs { url: url1, text: text1 } and the 100 needs { url: url100, text: text100 }.

So if that happens I will have to call MyLogic component 100 times.

<MyLogic {...{ url: url1, text: text1 }} />
<MyLogic {...{ url: url2, text: text2 }} />
...
<MyLogic {...{ url: url97, text: text97 }} />
<MyLogic {...{ url: url98, text: text98 }} />
... // and so on

IMPORTANT

I didn’t explain an important part.

The reason why I need this is because I am using an external service that reads a prop by its name;

read: [{ name: 'text1', url: 'url1' }, name: 'text2', url: 'url2', ... }]

That’s the way it reads the value of the prop. Maybe doing something like: { name: 'input.text1' } etc. Don’t know if you got my point.

So how can I handle this in the most dynamic way possible?

126 thoughts on “Is there a way to pass props with a dynamic index like link{1}, link{2}, etc?”

  1. Pingback: new keto diet
  2. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that
    automatically tweet my newest twitter updates. I’ve been looking for a
    plug-in like this for quite some time and was hoping maybe
    you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading
    your blog and I look forward to your new updates.

    Reply
  3. Hmm it looks like your blog ate my first comment (it was super
    long) so I guess I’ll just sum it up what I submitted and say, I’m thoroughly enjoying your blog.
    I too am an aspiring blog blogger but I’m still new to
    everything. Do you have any suggestions for newbie blog writers?

    I’d genuinely appreciate it.

    Reply
  4. Magnificent beat ! I would like to apprentice even as you amend your web site, how
    can i subscribe for a weblog website? The account aided me a applicable deal.
    I had been tiny bit familiar of this your broadcast offered
    shiny transparent concept

    Reply
  5. Thanks for one’s marvelous posting! I seriously enjoyed reading it, you could be a great author.I will always bookmark your
    blog and will come back later on. I want to encourage you to definitely
    continue your great writing, have a nice weekend!

    Reply
  6. Hey I know this is off topic but I was wondering
    if you knew of any widgets I could add to my blog that automatically tweet my
    newest twitter updates. I’ve been looking for a plug-in like this for quite
    some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading your
    blog and I look forward to your new updates.

    Reply
  7. Pingback: tamoxifen gel
  8. Pingback: clomid pill online
  9. Pingback: aralen hives
  10. Pingback: molnipiravir
  11. Pingback: rory latisse
  12. Pingback: tizanidine sale

Leave a Comment