-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Description
I have a list of breaking changes that I'd like to see because I think they're not strictly necessary features, can often be replaced by other APIs and their very existence makes implementations more constrained, even when they're not used.
This list is not meant to be anything we're planning on actively doing. It's just a drop point where I can add things as I think of them.
-
Shallow freeze the
defaultPropsobject and make thedefaultPropsproperty non-configurable/non-writable after the firstcreateElementorcreateFactorycall. (Enables inlining/resolution of defaults statically.) -
Treat
key/refas a separate namespace in JSX. Meaning that objects that are spread onto JSX don't transferkeyandref. Enables inlining of props object even if spread type is unknown. E.g.
let x = <Foo {...{key:'bar'}} />;
x.key; // null
x.props.key; // 'bar'
let y = <Foo key="bar" />;
y.key; // 'bar'
y.props.key; // undefined-
Drop support for string refs.
-
Drop support for
ReactDOM.findDOMNode(...)andReactNative.findNodeHandle(...). These are slower in Fiber and requires a tree to be materialized/stateful/introspectable at arbitrary times/threads even before we know if this will ever get called. Less automatic cleanup. Could possibly have an alternative API that works more like refs. However, just ref forwarding probably solves all legit use cases better. -
Make
.typeand.propsprivate onReactElements so that they can't be introspected (just like bound functions/closures). This makes optimizations like automatic making components asynchronous/synchronous safe or inlining components several levels deep.