basecamp / trix

A rich text editor for everyday writing
https://trix-editor.org/
MIT License
19.12k stars 1.12k forks source link

Deprecation of DefaultProps #1155

Open OtherCroissant opened 5 months ago

OtherCroissant commented 5 months ago

Hi, First of all, really enjoying the current progress on the Trix editor.

I get a deprecation warning for the use of JavaScript DefaultProps being replaced by JavaScript default parameters:

Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.

It looks like trix uses it here:

function _jsx(e, r, E, l) {
  REACT_ELEMENT_TYPE || (REACT_ELEMENT_TYPE = "function" == typeof Symbol && Symbol.for && Symbol.for("react.element") || 60103);
  var o = e && e.defaultProps,
    n = arguments.length - 3;
  if (r || 0 === n || (r = {
    children: void 0
  }), 1 === n) r.children = l;else if (n > 1) {
    for (var t = new Array(n), f = 0; f < n; f++) t[f] = arguments[f + 3];
    r.children = t;
  }
  if (r && o) for (var i in o) void 0 === r[i] && (r[i] = o[i]);else r || (r = o || {});
  return {
    $$typeof: REACT_ELEMENT_TYPE,
    type: e,
    key: void 0 === E ? null : "" + E,
    ref: null,
    props: r,
    _owner: null
  };
}

Maybe this could be fixed with the next minor update?

afcapel commented 5 months ago

That is not actually used anywhere in Trix, Babel is the one adding that cruft. I think we can remove Babel from the toolchain. We are not using any feature that is not supported by every target browser.

OtherCroissant commented 4 months ago

@afcapel That sounds good! Is it just removing it from the dependency list of the trix package? Maybe I can PR that...

OtherCroissant commented 3 months ago

@afcapel I did PR attempting to remove the babel stuff. Could you have a look at it some time?