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
-
What you have tried?ravibagul91– ravibagul912019-07-29 07:21:32 +00:00Commented Jul 29, 2019 at 7:21
-
@ravibagul91 I can not find examples (gomez– gomez2019-07-29 07:24:45 +00:00Commented 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.Ovidiu G– Ovidiu G2019-07-29 07:25:00 +00:00Commented Jul 29, 2019 at 7:25
Add a comment
|
1 Answer
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
6 Comments
gomez
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 ?
Ovidiu G
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.
gomez
Thanks, understood, I will test, and can I add components to the array?
Ovidiu G
Technically you can add markup as a string but it's not best practice. I'm sure you can find some other alternatives.
gomez
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
|
