Merge pull request #4802 from backstage/rugvip/onestore
core-api: skip wrapping the component data store in an object
This commit is contained in:
@@ -100,19 +100,16 @@ describe('elementData', () => {
|
||||
const element = <Component />;
|
||||
const container = (global as any)[
|
||||
'__@backstage/component-data-store__'
|
||||
].store.get(element.type);
|
||||
].get(element.type);
|
||||
expect(container.map.get('my-data')).toBe(data);
|
||||
});
|
||||
|
||||
it('should should be able to attach data for newer versions', () => {
|
||||
const data = { foo: 'bar' };
|
||||
const Component = () => null;
|
||||
(global as any)['__@backstage/component-data-store__'].store.set(
|
||||
Component,
|
||||
{
|
||||
map: new Map([['my-data', data]]),
|
||||
},
|
||||
);
|
||||
(global as any)['__@backstage/component-data-store__'].set(Component, {
|
||||
map: new Map([['my-data', data]]),
|
||||
});
|
||||
|
||||
const element = <Component />;
|
||||
expect(getComponentData(element, 'my-data')).toBe(data);
|
||||
|
||||
@@ -33,9 +33,10 @@ type MaybeComponentNode = ReactNode & {
|
||||
};
|
||||
|
||||
// The store is bridged across versions using the global object
|
||||
const { store } = getGlobalSingleton('component-data-store', () => ({
|
||||
store: new WeakMap<ComponentType<any>, DataContainer>(),
|
||||
}));
|
||||
const store = getGlobalSingleton(
|
||||
'component-data-store',
|
||||
() => new WeakMap<ComponentType<any>, DataContainer>(),
|
||||
);
|
||||
|
||||
export function attachComponentData<P>(
|
||||
component: ComponentType<P>,
|
||||
|
||||
Reference in New Issue
Block a user