Skip to content

{location: 'replace'} doesn't work in stateService.go(stateName, params, {location: 'replace'}) #1223

Description

@Fangfanghao

Hi,
In my demo, I did this:
index.tsx:

ReactDOM.render(
    <UIRouter router={router}>
        <div>
            <h1>Dynamic Example</h1>
            <UIView />
        </div>
    </UIRouter>,
    document.querySelector('#root'),
);

router.config.ts:

export const router = new UIRouterReact();
const plugins = [
    servicesPlugin,
    hashLocationPlugin,
];
plugins.forEach(plugin => {
    router.plugin(plugin);
});

// Register the initial (eagerly loaded) states
states.forEach((state) => router.stateRegistry.register(state));

When I call

let num = 1;
const DynamicExample: ReactStateDeclaration = {
   name: 'dynamic',
   url: 'dynamic/?queryParam1',
   component: (props) => {
       const $state = props.transition.router.stateService;
       return (
           <button
               onClick={() => {
                   $state.go('dynamic', { queryParam1: num++ }, { location: 'replace'});
               }}
           >
               only change queryParam1
           </button>
       );
   }}

in my code, the history.length still increased.

Correct me if I'm wrong. Thank you.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions