create-react-app supports importing JSON files right out-of-the-box. For example, you can import a JSON file in the following way:
import products from '../path/to/products.json';
This works because create-react-app uses webpack internally, which (from version 2+) includes json-loader
by default.
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.