skyra-project / discord-components

Discord Webcomponents for real looking messages on the web
https://discord-components.js.org
MIT License
250 stars 40 forks source link

bug: Components (React) do not work well with mutable data #297

Closed Kyzegs closed 3 months ago

Kyzegs commented 1 year ago

Describe the bug

Changing state/data will break various components. I've tested this with a few components. You'll be able to mess around with the issues in the CodeSandbox.

To Reproduce

CodeSandbox

Expected behavior

The components should keep working when state/data is mutated.

Screenshots

The field title is missing even though there is a value for it:

Missing field title

Additional context

Error when mutating message content:

NotFoundError
Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
favna commented 1 year ago

This is a known issue and will be resolved with the Lit Element rewrite, however I've been majorly lacking motivation to continue that branch.

TheBv commented 1 year ago

Any chance you could write down what the current status of the rewrite is/ what is missing? I'd be willing to continue your work, but some rough outline on what needs to be done would be very much appreciated :)

favna commented 1 year ago

I can write a more detailed explanation after work, but in short the progress is in the rewrite branch and the components ported are: https://github.com/skyra-project/discord-components/tree/feat/rewrite-to-lit/packages/core/src/components

That said, I also don't quite recall to what state those components were done.

favna commented 7 months ago

This should be resolved in the new alpha version. A full release of that version will come in due time, can't give an exact time frame. I want to work through a few other issues and I still have to add list item components. You can use the alpha releases though. The README has been updated to provide templates for many different stacks.

Kyzegs commented 7 months ago

I'll check it out. Thank you for the awesome work!

favna commented 3 months ago

I'm going to close this because OP hasn't replied anymore. I will assume that v4 has fixed this issue. If it hasn't, please reply again.