Created
November 11, 2018 13:24
-
-
Save productioncoder/f773e41142650ba6b310f7b6edf3fd83 to your computer and use it in GitHub Desktop.
Youtube in React: get search param
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getSearchParam = (location, name) => { | |
if (!location || !location.search) { | |
return null; | |
} | |
const searchParams = new URLSearchParams(location.search); | |
return searchParams.get(name); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment