Custom UI Plugin: Cannot add property __, object is not extensible
See original GitHub issueHello,
I’m trying to create a new UI plugin and whenever I’m trying to use it, by that specifying a target or add it as an option in DashboardModal, I’m getting this error:
Unhandled Rejection (TypeError): Cannot add property __, object is not extensible
I tried multiple ideas similar with ProgressBar and StatusBar but nothing workable so far. What I’m aiming is to replace progress bar in Dashboard with another content section for advanced details (ex: a table).
So far, one of my trying plugins is like this:
const { UIPlugin } = require('@uppy/core')
export default class CsvUi extends UIPlugin {
// eslint-disable-next-line global-require
constructor (uppy, opts) {
super(uppy, opts)
this.type = 'progressindicator'
this.id = this.opts.id || 'csvui'
this.title = 'CsvUi'
const defaultOptions = {}
this.opts = { ...defaultOptions, ...opts }
}
render = (state) => {
return (
<div style={{backgroundColor: 'red'}}>testing this plugin</div>
)
}
install () {
const { target } = this.opts
if (target) {
this.mount(target, this)
}
}
uninstall () {
this.unmount()
}
}
Note: if you’re trying to add a target like ‘.Dashboard’ or ‘body’ or you’re using it in your React app like this, is gonna give you the mentioned error:
<DashboardModal
uppy={uppy}
closeModalOnClickOutside
open={modalOpen}
id="dashboard"
onRequestClose={handleClose}
doneButtonHandler={false}
plugins={['csvui']}
showProgressDetails={false}
/>
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
TypeError: can't define property "x": "obj" is not extensible
To fix this error, you will either need to remove the call to Object.preventExtensions() entirely, or move it to a position so that...
Read more >React : cannot add property 'X', object is not extensible
I want to add a property 'LegendPosition' with the props in this component. I am unable to do that. Please help me with...
Read more >TypeError: Cannot add property __, object is not extensible ...
I'm trying to run a very simple story: import React,{ h, Component } from 'react'; import Input from '../components/helpers/Input'; export ...
Read more >cannot add property onclick, object is not extensible - You.com
The JavaScript exception "can't define property "x": "obj" is not extensible" occurs when Object.preventExtensions () marked an object as no longer extensible, ...
Read more >Editing Properties | Plugin API - Figma
Editing Properties. In many cases, editing a node property is as straightforward as changing a property on a regular node object.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A UI plugin’s render function must return Preact elements, not React elements, I think that might be what’s wrong here. If you do this at the top of your plugin file it might do the trick:
(and add preact as a dependency in your project.)
If so we could probably detect React elements in our ui plugin code and throw a more helpful error.
Closing this to keep the issue count maintainable. Feel free to continue the discussion here if the issue persists and we’ll help.