8 examples of 'usehistory in class component' in JavaScript

Every line of 'usehistory in class component' 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
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 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}
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}
114public onClick(event) {
115 event.target.select();
116}
16export default function HistoryHandler( { children } ) {
17 const ref = useRef();
18 const { undo, redo } = useDispatch( 'core/editor' );
19
20 useEffect( () => {
21 const onBeforeInput = ( event ) => {
22 if ( event.inputType === 'historyUndo' ) {
23 event.preventDefault();
24 undo();
25 } else if ( event.inputType === 'historyRedo' ) {
26 event.preventDefault();
27 redo();
28 }
29 };
30
31 ref.current.addEventListener( 'beforeinput', onBeforeInput );
32
33 return () => {
34 ref.current.removeEventListener( 'beforeinput', onBeforeInput );
35 };
36 } );
37
38 return (
39 <div>
40 { children }
41 </div>
42 );
43}
60$("#historyChangeButton").click(function historyChangeButtonClick(){
61 self.backToTheFuture();
62 $("#historyButton span").removeClass("navigation-bar-active-item");
63 $("#historyButton label").removeClass("navigation-bar-active-item");
64 $historyBox.toggle();
65});
25export function useHistory() {
26 return useContext(HistoryContext);
27}
12function useHistoryEntry( {
13 story,
14 current,
15 pages,
16 selection,
17 capabilities,
18} ) {
19 const { actions: { appendToHistory } } = useHistory();
20 useEffect( () =&gt; {
21 appendToHistory( {
22 story,
23 current,
24 pages,
25 selection,
26 capabilities,
27 } );
28 }, [ appendToHistory, story, current, pages, selection, capabilities ] );
29}

Related snippets