10 examples of 'this.props.history.push' in JavaScript

Every line of 'this.props.history.push' 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
this disclaimer
6function pushHistory(e, props) {
7 e.preventDefault()
8 props.onClick && props.onClick()
9 history.push({
10 pathname: props.to,
11 search: e.target.search
12 })
13}
Important

Use secure code every time

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

23export function History(props: HistoryProps) {
24 React.useEffect(() => {
25 if (process.env.NODE_ENV !== 'production') {
26 console.warn(
27 `Deprecation Warning: "<History>" is deprecated. It will be removed in a future version.`,
28 )
29 }
30 }, [])
31
32 return (
33 <NaviContext.Consumer>
34 {context => props.children(context.navigation._history)}
35 </NaviContext.Consumer>
36 )
37}
20setHistory(history: CustomHistory) {
21 this.history = history
22}
28push(params = {}) {
29 return NavigationSpecific.push(this, params);
30}
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}
28push(props, route) {
29 let routesList = this.navigator.getCurrentRoutes()
30 let nextIndex = routesList[routesList.length - 1].index + 1
31 route.props = props
32 route.index = nextIndex
33 this.navigator.push(route)
34}
19push(props, route) {
20 if(!props){
21 props = {};
22 }
23 route.props = props;
24 this.navigator.push(route);
25}
76push(state) {
77 const newHistory = this.merge({
78 undos: this.undos.push(snapshot(state, this.merged)),
79 redos: new Stack(),
80 merged: 1
81 });
82
83 return newHistory.prune();
84}
8return function history(state = initialState, action = {}) {
9
10 switch (action.type) {
11 case 'ADD_HISTORY':
12 state.data.push(action.page)
13 return state
14
15 // 清空
16 case 'CLEAN':
17 return {
18 data: []
19 }
20
21 default:
22 return state
23 }
24
25}
26constructor(props) {
27 super(props);
28
29 this.state = {
30 trade: true,
31 account: true,
32 signer: true,
33 trustline: true,
34 };
35
36 this.bindedScroll = this.scrollHandler.bind(this);
37
38 this.listenId = this.props.d.history.event.listen(() => {
39 this.forceUpdate();
40 });
41}

Related snippets