question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom UI Plugin: Cannot add property __, object is not extensible

See original GitHub issue

Hello,

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:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
goto-bus-stopcommented, Aug 31, 2021

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:

/** @jsx h */
import { h } from 'preact'

(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.

0reactions
Murderloncommented, Sep 8, 2021

Closing this to keep the issue count maintainable. Feel free to continue the discussion here if the issue persists and we’ll help.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found