getInitialData of jql-editor-autocomplete-rest is called only once even if the function is changed


I’m trying to introduce jql-editor into my product that uses oauth 3lo auth.
The special thing is the app can change the site the user issue the query interactively.

When I developed POC following the doc, I found the getInitialData is called only once even if the function object is changed.
I tried remounting the JQL editor. But it didn’t work. It seemed that the state is managed out of the JQL editor component.
I want to have the lib call the getInitialData again when the function changes.

Is there any way to achieve it? If no, how can I request this suggestion?


Hey @takafumiohtake we use react-sweet-state internally for state management. The jql-editor-autocomplete-rest package exports a JQLAutocompleteContainer component which you can use to re-initialise the store. If you render this as a parent of the component invoking useAutocompleteProvider then re-mounting the container should result in the desired behaviour, e.g.

import { JQLEditor } from '@atlassianlabs/jql-editor';
import { JQLAutocompleteContainer, useAutocompleteProvider } from '@atlassianlabs/jql-editor-autocomplete-rest';

const MyEditor = () => {
  const autocompleteProvider = useAutocompleteProvider(...);
  return <JQLEditor {...} />

const App = () => {
  return (
    <JQLAutocompleteContainer key={propToForceRemount}>
      <MyEditor />

Hi @Kyle

Thank you for your prompt reply.
Your code worked perfectly!!

Thanks a lot!

1 Like

No problem @takafumiohtake that’s great to hear!

1 Like