0

How create in React + jsx dropdown list with change content ?, I have two components (Product1, Product2). Include component my data (html), i want displayed necessary components when select

enter image description here

3
  • What you have tried? Commented Jul 29, 2019 at 7:21
  • @ravibagul91 I can not find examples ( Commented Jul 29, 2019 at 7:24
  • If you have your data coming in as a JSON with title and content you can simply display the title in the dropdown list and add an onSelect event in which you can display the content according to the selected title. (based on title id or something like that). We can't help much unless you show us what you have so far. Commented Jul 29, 2019 at 7:25

1 Answer 1

1

I'm not sure if this is exactly what you wanted to achieve but here's one option on how you can do it: codesandbox

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

6 Comments

your used array for data, but how i can change items via components ? Example: in product 1 component i have input,img, text (some design) and in product 2 component i have fields, img. May i call call components when select item from list ?
Well, you typically have some data coming in that you display in the form of markup (p tags, inputs and so on). If you can set up a basic codesandbox of your code it will be much easier to understand what you're trying to accomplish.
Thanks, understood, I will test, and can I add components to the array?
Technically you can add markup as a string but it's not best practice. I'm sure you can find some other alternatives.
can you show below link ? give this error "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:" codesandbox.io/s/funny-thompson-3hx50
|

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.