How to use the history/lib/DOMStateStorage.readState function in history

To help you get started, we’ve selected a few history examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phylogeny-explorer / explorer / client / src / client.js View on Github external
function onLocationChange(location) {
    // Save the page scroll position into the current location's state
    if (currentLocation.key) {
      saveState(currentLocation.key, {
        ...readState(currentLocation.key),
        scrollX: windowScrollX(),
        scrollY: windowScrollY(),
      });
    }
    currentLocation = location;
    UniversalRouter.resolve(routes, {
      path: location.pathname,
      query: location.query,
      state: location.state,
      context,
      render: render.bind(undefined, container, location), // eslint-disable-line react/jsx-no-bind, max-len
    }).catch(err => console.error(err)); // eslint-disable-line no-console
  }
github taion / scroll-behavior / modules / withStandardScroll.js View on Github external
savePositionHandle = requestAnimationFrame(() => {
        savePositionHandle = null

        const state = readState(currentKey)
        const scrollPosition = [ scrollLeft(window), scrollTop(window) ]

        // We have to directly update `DOMStateStorage`, because actually
        // updating the location could cause e.g. React Router to re-render the
        // entire page, which would lead to observably bad scroll performance.
        saveState(currentKey, { ...state, scrollPosition })
      })
    }
github taion / scroll-behavior / src / ScrollBehavior.js View on Github external
readPosition(location, key) {
    return readState(this._getKey(location, key));
  }
github catamphetamine / react-pages / source / client / history.js View on Github external
function get_history_state_location(history_state)
{
	const key = history_state && history_state.key

	return createLocation
	({
		pathname : window.location.pathname,
		search   : window.location.search,
		hash     : window.location.hash,
		state    : key ? readState(key) : undefined
	},
	undefined,
	key)
}
github catamphetamine / react-pages / source / redux / client / history store.js View on Github external
export function get_from_history(prefix, key)
{
	return readState(compute_key(prefix, key))
}