Answer the question
In order to leave comments, you need to log in
How to pass object/data from external file to React component?
So that's the idea.
I have a file that contains information about different products. For example: name, its contents.
Next, there is a React component, to which data (depending on the condition) about one of the products must be transferred, to render the product accordingly.
That is, if it were regular JS. I would call the object's constructor, thereby creating different products, after which I would connect the file to the document, and, depending on the conditions, fill the layout product with the corresponding data from the object.
But how to do this in React?
Answer the question
In order to leave comments, you need to log in
If your file is js, then you import it, throw it into the component and then pull the data you need
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question