Commit 14d75c42 authored by Robert Knight's avatar Robert Knight

Remove `propTypes` handling in `service-context.js`

We no longer set `propTypes` on components.
parent 3ab698f1
......@@ -44,7 +44,7 @@ export const ServiceContext = createContext(fallbackInjector);
* Wrap a React component to inject any services it depends upon as props.
*
* Components declare their service dependencies in an `injectedProps` static
* property. These services also need to be declared in `propTypes`.
* property.
*
* Any props which are passed directly will override injected props.
*
......@@ -97,12 +97,6 @@ export function withServices(Component) {
const wrappedName = Component.displayName || Component.name;
Wrapper.displayName = `withServices(${wrappedName})`;
// Forward the prop types, except for those expected to be injected via
// the `ServiceContext`.
Wrapper.propTypes = { ...Component.propTypes };
Component.injectedProps.forEach(prop => {
delete Wrapper.propTypes[prop];
});
return Wrapper;
}
......
import { mount } from 'enzyme';
import { render } from 'preact';
import propTypes from 'prop-types';
import { ServiceContext, withServices, useService } from '../service-context';
......@@ -40,20 +39,6 @@ describe('sidebar/service-context', () => {
assert.calledWith(injector.get, 'aService');
});
it('copies propTypes except for injected properties to wrapper', () => {
function TestComponent() {}
TestComponent.propTypes = {
notInjected: propTypes.string,
injected: propTypes.string,
};
TestComponent.injectedProps = ['injected'];
const Wrapped = withServices(TestComponent);
assert.deepEqual(Wrapped.propTypes, { notInjected: propTypes.string });
assert.isUndefined(Wrapped.injectedProps);
});
it('does not look up services if they are passed as props', () => {
const testService = {};
const injector = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment