-
Notifications
You must be signed in to change notification settings - Fork 0
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
TypeError: model.menuItems is not a function or its return value is not iterable #51
Comments
We changed menuItems to be a function rather than a "getter". So if you have code in your plugin that says "get menuItems()" just change it to "menuItems()" If you found any code out there that you are using that still uses the "get menuItems()" code let me know...I can update it |
(note that the reason for this change is that the functions can be overridden while referrring to the parent behavior while getters can't really. here is an example of that overriding) const Parent=types.model({}).views(self=>({
menuItems() {
console.log('parent menu items function')
return [...parent menu item stuff here]
}
}))
const Child = types.compose(Parent,types.model({}).views(self=>{
const {menuItems:parentMenuItems} = self
return {
menuItems() {
return [...parentMenuItems(), ...add more child menu items...]
}
}
}) |
Thank you for your reply. After reading your reply, I find the reason here. The error was thrown in: jbrowse-components/packages/app-core/src/ui/App/ViewMenu.tsx <CascadingMenu
menuItems={[
...model.menuItems(),
]}
/> the model doesn't has menuItems, so get TypeError: model.menuItems is not a function or its return value is not iterable and then I go to the default code in: jbrowse-plugin-jb3d/src/HelloView/stateModel.ts const stateModel = types
.model({
id: ElementId,
type: types.literal('HelloView'),
})
.actions(() => ({
// unused but required by your view
setWidth() {},
})) I didn't add any menuItems here, so I add code: .views(() => ({
menuItems(): MenuItem[] {
return [
{
label: 'Example item',
onClick: () => {
console.log('Example item clicked');
},
},
]
},
})) and then problem solved. |
Hello,
I've encountered an issue while attempting to build a demo plugin following the provided instructions, and I'm seeking guidance in resolving it.
instructions
https://github.com/GMOD/jbrowse-plugin-template/blob/main/README.md
https://github.com/GMOD/jbrowse-components/blob/main/CONTRIBUTING.md
enviroments
issue
When I finished these instruction, I visit the url: http://localhost:3000/?config=http://localhost:9000/jbrowse_config.json
and then open hello view, I got this error:
and also tried
yarn browse
: http://localhost:8999/Thank you in advance for your time and help.
The text was updated successfully, but these errors were encountered: