Bug with initialUiState. #5378
Replies: 0 comments 14 replies
-
Hi @bootsmann1995 usually when you want to add state from the server, you'd rely the routing feature, and so you'd be able to pass a state via the url like this: https://github.com/algolia/vue-instantsearch/blob/master/examples/ssr/src/main.js#L44-L45. Can this work for you? Otherwise, PRs are more than welcome! |
Beta Was this translation helpful? Give feedback.
-
@tkrugg Thanks for the answer :) How would you implement it with an object? and isn't this Vue3 ? i'm using nuxt, and it's only in vue2 for now. |
Beta Was this translation helpful? Give feedback.
-
i'm currenly using this router:
it works fine with server navigation. But when routing with nuxt-router it clears the url |
Beta Was this translation helpful? Give feedback.
-
otherwise is it possible to set the uiState after render? @tkrugg @Haroenv |
Beta Was this translation helpful? Give feedback.
-
you can set the ui state after render with instantsearchInstance.setUiState, but I still don't get why routing doesn't work for your use case. Continuing to ping individual people instead of using [email protected] however is messing with our processes and as always you haven't given a sandbox for debugging, could you stop doing that please? |
Beta Was this translation helpful? Give feedback.
-
Haroenv yes ofc. sorry for this. It's just because this issue is under time pressure. I want to set the route based on an object fetched from an api. But if i push my parameter to my router on created it just clears my parameters after load? I sent my algolia routing further up in this thread. It works when routing directly to the page. but not when using vue-router navigation. |
Beta Was this translation helpful? Give feedback.
-
If you use routing, you can't also use initial UI state, they both act on the same information and routing takes precedence. What you should do is:
Hope that makes sense! |
Beta Was this translation helpful? Give feedback.
-
Thank you for the answer, do you have an example on this? otherwise i'll try make it work with these steps. |
Beta Was this translation helpful? Give feedback.
-
something approximately like this: https://codesandbox.io/s/awesome-architecture-shex2?file=/src/App.vue |
Beta Was this translation helpful? Give feedback.
-
But if I don't have the data from asyncData() in this hook, this sets me back to square one still right? |
Beta Was this translation helpful? Give feedback.
-
the data in asyncData happens after data if I remember it correctly, without a full example of what you want to do it will be hard to help you out. I recommend simplifying the logic so the state can be derived directly from the page instead of needing a network request |
Beta Was this translation helpful? Give feedback.
-
Okay do you have a nuxt template. then I'll create a full example for you to clarify :) But it's because we give the content editor the possibility to pre select a value for the uistate on the cms. and we fetch data from cms in asyncData bc of the static site generation. |
Beta Was this translation helpful? Give feedback.
-
https://codesandbox.io/s/patient-cdn-393wm?file=/pages/search.vue |
Beta Was this translation helpful? Give feedback.
-
Bug 🐞
What is the current behavior?
ais-instant-search-ssr does not support :initial-ui-state feature. I need this on server side since I want to preconfigure my search based on something from my headless cms. And I can't do this in my setup.
I'm using Nuxt Algolia implemented like in your docs:
I can't use my properties in data() from headless cms so I need some way to set this initialUiState when my cms data is available-
What is the expected behavior?
The expected behavior is I can set my initialUiState programatically. something like this:
What is the version you are using?
"algoliasearch": "^4.9.3",
"vue-instantsearch": "^3.7.0",
Beta Was this translation helpful? Give feedback.
All reactions