RoutetoState is not sending data to StatetoRoute

I’m working on setting up URL routing for instant search following these steps:

       stateMapping: {
stateToRoute(uiState) {      
  return {
    query: uiState.query,
    refinements: uiState.refinements,
  };
},

routeToState(routeState) {
      return {
        query: 'test',
        refinements: {
          technology: routeState.refinements,
        },
      };
    },
},

Then I have createURL
return ${baseUrl}search${queryString};

This should append ?query=test to my URL

However my RoutetoState isn’t sending the query to StatetoRoute. If I change the query: ‘test’ directly in StatetoRoute this will work as expected.

I’m not sure what I’m doing wrong and any help will be great!

Thank You!

Hi,

The code you wrote should work. I have an example which is almost exactly the same as what you’re describing here:

Could you edit that example and send that to show what’s not behaving as expected?

Thanks!