Sha256: 8ba4353aab460a23f583c947d903fa664f289f6b35e1f25472c0dc3c1bc06ce9
Contents?: true
Size: 517 Bytes
Versions: 78
Compression:
Stored size: 517 Bytes
Contents
import qs from 'query-string'; /* For when you have a hash with your params in the URL pass in the the 'hash' object from react-router's useLocation(); e.g. "mysite.com/foo#bar?baz=bop" will return { hash: 'bar', params: { baz: "bop" }} */ const paramsFromHash = (hash) => { const [baseHash, queryParams = {}] = hash.split('?'); const params = qs.parse(queryParams); const trimmedHash = baseHash.replace('#', '').replace('/', ''); return { hash: trimmedHash, params }; }; export default paramsFromHash;
Version data entries
78 entries across 78 versions & 1 rubygems