10 examples of 'usehistory' in JavaScript

Every line of 'usehistory' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
31export function useHistory>({
32 pushOn,
33}: {
34 pushOn: TParams
35}): void {
36 const isMounted = useRef(false)
37
38 useEffect(() => {
39 if (!isMounted.current) {
40 isMounted.current = true
41 return
42 }
43
44 pushState(removeEmpty(pushOn))
45 }, [JSON.stringify(pushOn)])
46}
5export function useHistory() {
6 let pathname = getPathname();
7 let [state, setState] = useState({ pathname });
8
9 useEffect(() => {
10 function handler() {
11 let pathname = getPathname();
12 setState(state =>
13 state.pathname != pathname ? { pathname } : state
14 );
15 }
16 return subscribe(handler);
17 }, []);
18 return [pathname, redirect];
19}
25export function useHistory() {
26 return useContext(HistoryContext);
27}
23export function History(props: HistoryProps) {
24 React.useEffect(() => {
25 if (process.env.NODE_ENV !== 'production') {
26 console.warn(
27 `Deprecation Warning: "" is deprecated. It will be removed in a future version.`,
28 )
29 }
30 }, [])
31
32 return (
33
34 {context => props.children(context.navigation._history)}
35
36 )
37}
5export function useHistory() {
6 if (process.env.NODE_ENV !== 'production') {
7 console.warn(
8 `Deprecation Warning: "useHistory()" is deprecated. It will be removed in a future version.`,
9 )
10 }
11
12 return React.useContext(NaviContext).navigation._history
13}
27function writeHistory(history) {
28 grunt.log.ok(`Writing updated lab history ${JSON.stringify(history, null, 2)}`)
29 fs.writeFileSync(historyPath, JSON.stringify(history, null, 2))
30 return history
31}
24[UNDO]() {
25 if (!this._history.length) return;
26 this._history[this._position = Math.max(Math.min(this._position - 1, this._history.length - 2), 0)].use();
27}
9export function useHistory() {
10 if (__DEV__) {
11 invariant(
12 typeof useContext === "function",
13 "You must use React >= 16.8 in order to use useHistory()"
14 );
15 }
16
17 return useContext(Context).history;
18}
12function useHistory() {
13 return useContext( Context );
14}
83updateHistory() {
84 if (count >= 18) {
85 colors.shift()
86 }
87 this.$items.forEach((v, i) => {
88 setStyle('background', colors[colors.length - 1 - i], v)
89 if (i < count) {
90 addClass(this.classes.HISTORYITEMEMPTY, v)
91 }
92 })
93}

Related snippets