B
B
brainexplosion2018-08-10 01:32:12
React
brainexplosion, 2018-08-10 01:32:12

How to move the common part of the project into a separate file using react+webpack?

There is a URL that is used for different components. It is necessary to put it in a separate file (so that if the URL changes, you do not have to search for it throughout the code). How to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
campus1, 2018-08-10
@brainexplosion

If I understood you correctly.
Make file routes.js
Write there

export const PAGE = { pageName: `/url/example`} // для роутинга
export const apiRoute = {getElement: '/get/element/:id'} // для api запросов

And then you can extend the PAGE and apiRoute objects import {PAGE} from 'config'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question