M
M
Maxim Kalinin2020-10-11 21:37:46
React
Maxim Kalinin, 2020-10-11 21:37:46

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

1 answer(s)
K
Kirill Makarov, 2020-10-12
@kirbi1996

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 question

Ask a Question

731 491 924 answers to any question