Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue3 plugin options from useFieldPlugin hook is undefined #356

Open
vickywane opened this issue Feb 17, 2024 · 2 comments
Open

Vue3 plugin options from useFieldPlugin hook is undefined #356

vickywane opened this issue Feb 17, 2024 · 2 comments

Comments

@vickywane
Copy link

Describe the bug
The options object from the useFieldPlugin is continuously undefined in my field plugins. I logged out the type also and I can see that it's stuck in a loading value.

I'm experiencing this on with the version "@storyblok/field-plugin": "1.0.1" and "vue": "^3.2.47". I also created a new project using version "@storyblok/field-plugin": "1.0.2",.

I really would love to get a fix for this as we need to use the same plugin for multiple StoryBlok spaces so we are relying on the options to switch the credentials.

To Reproduce
Steps to reproduce the behavior:

Log out the options object from the useFieldPlugin as shown below;

  <script setup lang="ts">
  import type { SetModalOpen } from '@storyblok/field-plugin'
  import { useFieldPlugin } from '@storyblok/field-plugin/vue3';
  
  const { data: pluginData, type: pluginType } = useFieldPlugin()
  
  console.log("PLUGIN OPTIONS", pluginData?.options);
  
  const props = defineProps<{
    isModalOpen: boolean
    setModalOpen: SetModalOpen<any>
  }>()
  </script>

Expected behavior
The options object should have the properties defined in the following field-plugin.config.json` file;

{
  "options": [
    {
      "name": "API_URL",
      "value": ""
    },
      {
        "name": "API_KEY",
        "value": ""
      }
  ]
}

Screenshots

Screenshot 2024-02-17 at 12 58 16

Additional context

@eunjae-lee
Copy link
Contributor

Hi @vickywane useFieldPlugin() returns a reactive object. So you cannot destructure it.

const plugin = useFieldPlugin()

I'd like to avoid this confusion. Would it help if the template included some comments about this?

@vickywane
Copy link
Author

Hi @eunjae-lee

Apologies here, I missed the notification about your response.

I think it would be very helpful for others also.

If this has not been included in the documentation, I will be more than happy to make a PR to contribute that if you point in the right direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants