kamil-lip / bootstrap-vue-treeview

A treeview component for Bootstrap and Vue.js 2.0+
MIT License
43 stars 30 forks source link

[Vue warn]: Invalid default value for prop "contextMenuItems": Props with type Object/Array must use a factory function to return the default value. #12

Open xellos00 opened 5 years ago

xellos00 commented 5 years ago

I have an issue with this error message ad default value: do you have any suggestion?

kamil-lip commented 5 years ago

it should be like this:

contextMenuItems: () => { return [ ….. ]; }

instead of:

contextMenuItems: […...]

On 22 Jun 2019, at 16:55, XellosDK notifications@github.com wrote:

I have an issue with this error message ad default value: do you have any suggestion?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kamil-lip/bootstrap-vue-treeview/issues/12?email_source=notifications&email_token=AA6GGNKINZMGTU73BCWYJ4DP3Y4OPA5CNFSM4H2W6SA2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G3DEI3A, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6GGNI74DKZNJJWX27IR4LP3Y4OPANCNFSM4H2W6SAQ.

maugch commented 3 years ago

Has anyone tested it?

SIMSDev3 commented 3 years ago

@kamil-lip Im sitting with this exact problem.

I have changed and rechanged the contextMenuItems prop default so many times with 0 success. The response above does not help at all.

I am definitely using factory function to return [], with 0 change in the console errors. I have tried:

1 - contextMenuItems: () =>{ return [{code: 'DELETE_NODE', label: 'Delete node'}, { code: 'ADD_CHILD_NODE', label: 'Add child' }, {code: 'RENAME_NODE', label: 'Rename'}] }

2 - contextMenuItems: () =>{ return [] }

3 - contextMenuItems: { type: Array, default: () => { return [{code: 'DELETE_NODE', label: 'Delete node'}, {code: 'RENAME_NODE', label: 'Rename node'}] } }

4 - contextMenuItems: { type: Array, default: () => { return [] } }

Nothing affected the console log spam.

This is very frustrating, the component is working 100% fine in terms of functionality, however the spam in console log is too much, and hindering my debugging of other elements.

Please update your GIT so we can get the correct version or at least help us get this resolved on our ends.

simonInOz commented 2 years ago

This is indeed frustrating. I don't want context menus, so they are disabled, but the the error messages continue. It doesn't seem to affect the operation, oddly, but the error messages are disconcerting.