How to use the connected-react-router.replace function in connected-react-router

To help you get started, we’ve selected a few connected-react-router 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 kalmhq / kalm / frontend / src / pages / NoMatch / index.tsx View on Github external
componentDidMount() {
    const { dispatch, location } = this.props;
    if (location.pathname === "/") {
      // auto redirect applications
      dispatch(replace("/applications"));
    } else {
      dispatch(replace("/404"));
    }
  }
github walmartlabs / concord / console2 / src / state / data / forms / index.ts View on Github external
// a form with branding
        let { uri } = yield call(apiStartSession, processInstanceId, formName);

        // we can't proxy html resources using create-react-app
        // so we have to use another server to serve our custom forms
        // this is only for the development
        uri = updateForDev(uri);

        window.location.replace(uri);
    } else {
        // regular form
        const path = {
            pathname: `/process/${processInstanceId}/form/${formName}/wizard`,
            search: `fullScreen=true&yieldFlow=${yieldFlow}`
        };
        yield put(replaceHistory(path));
    }
}
github kalmhq / kalm / frontend / src / pages / Application / Log.tsx View on Github external
const { activeNamespaceName } = this.props;

    if (!window.location.search) {
      this.props.dispatch(push(`/applications/${activeNamespaceName}/components`));
    }

    if (prevState.subscribedPods.length !== this.state.subscribedPods.length || this.state.value !== prevState.value) {
      // save selected pods in query
      const search = {
        ...queryString.parse(window.location.search.replace("?", "")),
        pods: this.state.subscribedPods.length > 0 ? this.state.subscribedPods : undefined,
        active: !!this.state.value[0] ? this.state.value : undefined,
      };

      this.props.dispatch(
        replace({
          search: queryString.stringify(search),
        }),
      );
    }

    this.initFromQuery();
  }
github Kinto / kinto-admin / src / sagas / route.js View on Github external
): SagaGen {
  const { name, params } = action;
  const next = url(name, params);
  const {
    router: {
      location: { pathname: current },
    },
  } = getState();
  if (next == current) {
    // In several places in the code base, we use redirectTo() with the current path
    // to refresh the state of the page (eg. refresh list after record deletion from the list).
    // In latest versions of react-router, redirecting to the same URL does not reload the page.
    // Tackling the issue at its core will happen in Kinto/kinto-admin#272
    // In the mean time, let's trick the router by going to a fake URL and replacing it immediately.
    yield put(updatePath("/--fake--"));
    yield put(replacePath(next));
  } else {
    yield put(updatePath(next));
  }
}
github nasa / earthdata-search / static / src / js / actions / savedProject.js View on Github external
.then((response) => {
      const { data } = response
      const {
        project_id: projectId,
        path
      } = data

      dispatch(updateSavedProject({
        name,
        path,
        projectId
      }))

      // If the URL didn't contain a projectId before, change the URL to a project URL
      if (search.indexOf('?projectId=') === -1) dispatch(replace(`${pathname}?projectId=${projectId}`))
    })
    .catch((error) => {
github nasa / earthdata-search / static / src / js / actions / urlQuery.js View on Github external
.then((response) => {
            const { data } = response
            const {
              project_id: newProjectId,
              path: projectPath
            } = data

            newOptions = `${projectPath.split('?')[0]}?projectId=${newProjectId}`

            if (projectId !== newProjectId) {
              dispatch(replace(newOptions))
            }

            dispatch(actions.updateSavedProject({
              path: projectPath,
              name,
              projectId: newProjectId
            }))
          })
          .catch((error) => {
github marmelab / react-admin / packages / ra-core / src / auth / useAuth.spec.tsx View on Github external
it('should logout, redirect to login and show a notification after a tick if the auth fails', async () => {
        const authProvider = jest.fn(type =>
            type === 'AUTH_CHECK' ? Promise.reject() : Promise.resolve()
        );
        const { dispatch } = renderWithRedux(
            
                {stateInpector}
            
        );
        await wait();
        expect(authProvider.mock.calls[0][0]).toBe('AUTH_CHECK');
        expect(authProvider.mock.calls[1][0]).toBe('AUTH_LOGOUT');
        expect(dispatch).toHaveBeenCalledTimes(2);
        expect(dispatch.mock.calls[0][0]).toEqual(
            replace({ pathname: '/login', state: { nextPathname: '/' } })
        );
        expect(dispatch.mock.calls[1][0]).toEqual(
            showNotification('ra.auth.auth_check_error', 'warning')
        );
    });
github TheThingsNetwork / lorawan-stack / pkg / webui / console / views / application-api-key-add / index.js View on Github external
    navigateToList: appId => dispatch(replace(`/applications/${appId}/api-keys`)),
  }),
github Superjo149 / auryo / src / common / store / auth / actions.ts View on Github external
ipcRenderer.once('login-success', () => {
            const { config: { lastLogin } } = getState();

            if (lastLogin) {
                dispatch(replace('/'));
            }

            dispatch(setConfigKey('lastLogin', Date.now()));
        });
    };
github decentraland / builder / src / modules / location / sagas.ts View on Github external
function* handleAuthSuccess(action: AuthSuccessAction) {
  const { options } = action.payload
  if (options.returnUrl) {
    yield put(replace(options.returnUrl))
  } else {
    const location: ReturnType = yield select(getLocation)
    if (location.pathname === locations.callback()) {
      yield put(replace(locations.root()))
    }
  }
  if (options.openModal) {
    yield put(openModal(options.openModal.name as any, options.openModal.metadata))
  }
}