dillon1000/react

Commit

Make createDescriptor return a descriptor for components

This moves all logic around legacy descriptors to ReactLegacyDescriptor. This
is responsible for the layer that knows that createClass exports a legacy
factory. When passed one of these classes, it unwraps it to be a real class.

If it is passed a non legacy factory, it is assumed to be a non-react component
that needs to be invoked as a plain function.

The semantic change is that a descriptor is now always returned if passed a
legacy factory. Even if that factory is a mock. A mock would previously return
undefined.

For mocks, I treat the factory as the authoritative function. I call it to extract
the instance or fill it with an empty component placeholder.

Additionally, I make the classes take props as the first argument to the
constructor. This is what the new class system will do.

We currently need to set up some internals by calling the internal construct
method. Instead of doing that automatically in the constructor, I now move that
to a second pass so that mocks can get the plain props.

This means that we can assert that a mock has been called once it's mounted
with it's final props. Instead of the descriptor factory being called.
Browse files
Changed paths11 files
First-parent comparison
M src/browser/ReactDOM.js ModifiedM src/browser/ReactTextComponent.js ModifiedM src/browser/ui/React.js ModifiedM src/core/ReactCompositeComponent.js ModifiedM src/core/ReactDescriptor.js ModifiedM src/core/ReactDescriptorValidator.js ModifiedM src/core/ReactLegacyDescriptor.js ModifiedM src/core/__tests__/ReactDescriptor-test.js ModifiedM src/core/instantiateReactComponent.js ModifiedM src/test/ReactTestUtils.js ModifiedM src/utils/traverseAllChildren.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…