I'm writing an app using React and trying to make a dynamic footer - I have a URL there that varies between pages
Is there any way to get URL params outside of page component somehow without copying footer to each page?
Are you using React Router? React Router v4+ contains a url query param.
const params = new URLSearchParams(this.props.location.search);
const foo = params.get('foo'); // bar
You can alternatively use window.location.hash
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.