React.js – Communicating between sibling components

TLDR: Yes, you should use a props-from-top-to-bottom and change-handlers-from-bottom-to-top approach. But this can get unwieldy in a larger application, so you can use design patterns like Flux or Redux to reduce your complexity. Simple React approach React components receive their “inputs” as props; and they communicate their “output” by calling functions that were passed to … Read more

How to store Configuration file and read it using React

With webpack you can put env-specific config into the externals field in webpack.config.js externals: { ‘Config’: JSON.stringify(process.env.NODE_ENV === ‘production’ ? { serverUrl: “https://myserver.com” } : { serverUrl: “http://localhost:8090” }) } If you want to store the configs in a separate JSON file, that’s possible too, you can require that file and assign to Config: externals: … Read more

how to cancel/abort ajax request in axios

Axios does not support canceling requests at the moment. Please see this issue for details. UPDATE: Cancellation support was added in axios v0.15. EDIT: The axios cancel token API is based on the withdrawn cancelable promises proposal. UPDATE 2022: Starting from v0.22.0 Axios supports AbortController to cancel requests in fetch API way: Example: const controller … Read more