cheap-di-react
Advanced tools
Comparing version 3.2.1 to 3.2.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./useContainer"), exports); | ||
(0, tslib_1.__exportStar)(require("./use"), exports); | ||
tslib_1.__exportStar(require("./useContainer"), exports); | ||
tslib_1.__exportStar(require("./use"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -31,5 +31,8 @@ "use strict"; | ||
}, [parentContainer]); | ||
const rerender = () => { | ||
setContextValue(Object.assign({}, contextValue)); | ||
}; | ||
return [ | ||
contextValue, | ||
() => setContextValue(Object.assign({}, contextValue)), | ||
rerender, | ||
]; | ||
@@ -36,0 +39,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./DiContext"), exports); | ||
(0, tslib_1.__exportStar)(require("./decorators"), exports); | ||
(0, tslib_1.__exportStar)(require("./Providers"), exports); | ||
(0, tslib_1.__exportStar)(require("./hooks/use"), exports); | ||
tslib_1.__exportStar(require("./DiContext"), exports); | ||
tslib_1.__exportStar(require("./decorators"), exports); | ||
tslib_1.__exportStar(require("./Providers"), exports); | ||
tslib_1.__exportStar(require("./hooks/use"), exports); | ||
//# sourceMappingURL=index.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./OneTimeProvider"), exports); | ||
(0, tslib_1.__exportStar)(require("./Provider"), exports); | ||
(0, tslib_1.__exportStar)(require("./SelfOneTimeProvider"), exports); | ||
(0, tslib_1.__exportStar)(require("./SelfProvider"), exports); | ||
tslib_1.__exportStar(require("./OneTimeProvider"), exports); | ||
tslib_1.__exportStar(require("./Provider"), exports); | ||
tslib_1.__exportStar(require("./SelfOneTimeProvider"), exports); | ||
tslib_1.__exportStar(require("./SelfProvider"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -9,7 +9,7 @@ "use strict"; | ||
const OneTimeProvider = props => { | ||
const { dependencies, children } = props, rest = (0, tslib_1.__rest)(props, ["dependencies", "children"]); | ||
const { dependencies, children } = props, rest = tslib_1.__rest(props, ["dependencies", "children"]); | ||
const registrations = (0, react_1.useMemo)(() => dependencies, []); | ||
return ((0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: registrations }, rest, { children: children }), void 0)); | ||
return ((0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: registrations }, rest, { children: children }))); | ||
}; | ||
exports.OneTimeProvider = OneTimeProvider; | ||
//# sourceMappingURL=OneTimeProvider.js.map |
import { DependencyRegistrator } from 'cheap-di'; | ||
import { FC } from 'react'; | ||
import { FC, ReactNode } from 'react'; | ||
interface ProviderProps { | ||
@@ -7,2 +7,3 @@ dependencies?: ((dependencyRegistrator: DependencyRegistrator) => void)[]; | ||
debugName?: string; | ||
children: ReactNode; | ||
} | ||
@@ -9,0 +10,0 @@ declare const memoizedComponent: FC<ProviderProps>; |
@@ -16,2 +16,3 @@ "use strict"; | ||
const [initialized, setInitialized] = (0, react_1.useState)(false); | ||
const timerRef = (0, react_1.useRef)(null); | ||
const [contextValue, rerender] = (0, hooks_1.useContainer)(logger); | ||
@@ -24,2 +25,3 @@ const container = contextValue.container; | ||
} | ||
container.clear(); | ||
logger.log('dependency registrations'); | ||
@@ -49,3 +51,3 @@ const singletonsSizeBeforeDependenciesUpdate = (_a = container === null || container === void 0 ? void 0 : container.getSingletons().size) !== null && _a !== void 0 ? _a : 0; | ||
logger.log('singletons size changed, trigger root rerender'); | ||
setTimeout(() => { | ||
timerRef.current = setTimeout(() => { | ||
container.rootContainer.rerender(); | ||
@@ -56,10 +58,18 @@ }); | ||
}, [container, dependencies]); | ||
(0, react_1.useEffect)(() => { | ||
return () => { | ||
if (timerRef.current) { | ||
clearTimeout(timerRef.current); | ||
} | ||
container === null || container === void 0 ? void 0 : container.clear(); | ||
}; | ||
}, []); | ||
if (!initialized) { | ||
return null; | ||
} | ||
return ((0, jsx_runtime_1.jsx)(DiContext_1.DiContext.Provider, Object.assign({ value: contextValue }, { children: (0, jsx_runtime_1.jsx)(MemoizedChildren, { children: children }, void 0) }), void 0)); | ||
return ((0, jsx_runtime_1.jsx)(DiContext_1.DiContext.Provider, Object.assign({ value: contextValue }, { children: (0, jsx_runtime_1.jsx)(MemoizedChildren, { children: children }) }))); | ||
}; | ||
const MemoizedChildren = (0, react_1.memo)(({ children }) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: children }, void 0)); | ||
const MemoizedChildren = (0, react_1.memo)(({ children }) => (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: children })); | ||
const memoizedComponent = (0, react_1.memo)(Provider); | ||
exports.Provider = memoizedComponent; | ||
//# sourceMappingURL=Provider.js.map |
@@ -5,4 +5,4 @@ "use strict"; | ||
const jsx_runtime_1 = require("react/jsx-runtime"); | ||
const react_1 = require("@testing-library/react"); | ||
require("@testing-library/jest-dom"); | ||
const react_1 = require("@testing-library/react"); | ||
const cheap_di_1 = require("cheap-di"); | ||
@@ -13,2 +13,6 @@ const decorators_1 = require("../decorators"); | ||
const hooks_1 = require("../hooks"); | ||
test('use jsdom in this test file', () => { | ||
const element = document.createElement('div'); | ||
expect(element).not.toBeNull(); | ||
}); | ||
describe('base cases', () => { | ||
@@ -37,8 +41,8 @@ class Logger { | ||
const logger = (0, hooks_1.use)(SomeConsoleLogger); | ||
return (0, jsx_runtime_1.jsx)("p", { children: logger.debug('another layout') }, void 0); | ||
return (0, jsx_runtime_1.jsx)("p", { children: logger.debug('another layout') }); | ||
}; | ||
const RootComponent = () => ((0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: [ | ||
dr => dr.registerType(SomeConsoleLogger), | ||
] }, { children: (0, jsx_runtime_1.jsx)(Component, {}, void 0) }), void 0)); | ||
const { queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {}, void 0)); | ||
] }, { children: (0, jsx_runtime_1.jsx)(Component, {}) }))); | ||
const { queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {})); | ||
expect(queryByText('another layout')).toBeInTheDocument(); | ||
@@ -49,8 +53,8 @@ }); | ||
const logger = (0, hooks_1.use)(Logger); | ||
return (0, jsx_runtime_1.jsx)("p", { children: logger.debug('my layout') }, void 0); | ||
return (0, jsx_runtime_1.jsx)("p", { children: logger.debug('my layout') }); | ||
}; | ||
const RootComponent = () => ((0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: [ | ||
dr => dr.registerType(ConsoleLogger).as(Logger), | ||
] }, { children: (0, jsx_runtime_1.jsx)(Component, {}, void 0) }), void 0)); | ||
const { queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {}, void 0)); | ||
] }, { children: (0, jsx_runtime_1.jsx)(Component, {}) }))); | ||
const { queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {})); | ||
expect(queryByText('my layout')).toBeInTheDocument(); | ||
@@ -61,8 +65,8 @@ }); | ||
const logger = (0, hooks_1.use)(Logger); | ||
return (0, jsx_runtime_1.jsx)("p", { children: logger.debug('my layout') }, void 0); | ||
return (0, jsx_runtime_1.jsx)("p", { children: logger.debug('my layout') }); | ||
}; | ||
const RootComponent = () => ((0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: [ | ||
dr => dr.registerType(ConsoleLogger).as(Logger).with('my message'), | ||
] }, { children: (0, jsx_runtime_1.jsx)(Component, {}, void 0) }), void 0)); | ||
const { queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {}, void 0)); | ||
] }, { children: (0, jsx_runtime_1.jsx)(Component, {}) }))); | ||
const { queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {})); | ||
expect(queryByText('my message: my layout')).toBeInTheDocument(); | ||
@@ -79,8 +83,8 @@ }); | ||
const database = (0, hooks_1.use)(Database); | ||
return ((0, jsx_runtime_1.jsx)("p", { children: database.entities.map(e => ((0, jsx_runtime_1.jsx)("span", { children: e }, e))) }, void 0)); | ||
return ((0, jsx_runtime_1.jsx)("p", { children: database.entities.map(e => ((0, jsx_runtime_1.jsx)("span", { children: e }, e))) })); | ||
}; | ||
const RootComponent = () => ((0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: [ | ||
dr => dr.registerInstance(new Database(entities)), | ||
] }, { children: (0, jsx_runtime_1.jsx)(Component, {}, void 0) }), void 0)); | ||
const { queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {}, void 0)); | ||
] }, { children: (0, jsx_runtime_1.jsx)(Component, {}) }))); | ||
const { queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {})); | ||
expect(queryByText(entities[0])).toBeInTheDocument(); | ||
@@ -92,10 +96,10 @@ expect(queryByText(entities[1])).toBeInTheDocument(); | ||
const logger = (0, hooks_1.use)(Logger); | ||
return (0, jsx_runtime_1.jsx)("p", { children: logger.debug('my layout') }, void 0); | ||
return (0, jsx_runtime_1.jsx)("p", { children: logger.debug('my layout') }); | ||
}; | ||
const RootComponent = () => ((0, jsx_runtime_1.jsxs)(Provider_1.Provider, Object.assign({ dependencies: [ | ||
dr => dr.registerType(ConsoleLogger).as(Logger).with('my message'), | ||
] }, { children: [(0, jsx_runtime_1.jsx)(Component, {}, void 0), (0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: [ | ||
] }, { children: [(0, jsx_runtime_1.jsx)(Component, {}), (0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: [ | ||
dr => dr.registerType(SomeConsoleLogger).as(Logger), | ||
] }, { children: (0, jsx_runtime_1.jsx)(Component, {}, void 0) }), void 0)] }), void 0)); | ||
const { queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {}, void 0)); | ||
] }, { children: (0, jsx_runtime_1.jsx)(Component, {}) }))] }))); | ||
const { queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {})); | ||
expect(queryByText('my message: my layout')).toBeInTheDocument(); | ||
@@ -106,3 +110,3 @@ expect(queryByText('my layout')).toBeInTheDocument(); | ||
describe('singleton and stateful', () => { | ||
test('singleton', (done) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { | ||
test('singleton', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
let MySingleton = class MySingleton { | ||
@@ -113,3 +117,3 @@ constructor() { | ||
loadData() { | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
this.data = yield Promise.resolve('loaded data'); | ||
@@ -119,3 +123,3 @@ }); | ||
}; | ||
MySingleton = (0, tslib_1.__decorate)([ | ||
MySingleton = tslib_1.__decorate([ | ||
cheap_di_1.singleton | ||
@@ -127,3 +131,3 @@ ], MySingleton); | ||
const RootComponent = () => { | ||
return ((0, jsx_runtime_1.jsxs)(Provider_1.Provider, Object.assign({ dependencies: dependencies }, { children: [(0, jsx_runtime_1.jsx)(LoadComponent, {}, void 0), (0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: dependencies }, { children: (0, jsx_runtime_1.jsx)(ReadComponent, {}, void 0) }), void 0)] }), void 0)); | ||
return ((0, jsx_runtime_1.jsxs)(Provider_1.Provider, Object.assign({ dependencies: dependencies }, { children: [(0, jsx_runtime_1.jsx)(LoadComponent, {}), (0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: dependencies }, { children: (0, jsx_runtime_1.jsx)(ReadComponent, {}) }))] }))); | ||
}; | ||
@@ -135,17 +139,16 @@ const buttonId = 'my-button'; | ||
mySingleton.loadData(); | ||
} }, void 0), (0, jsx_runtime_1.jsx)("span", { children: mySingleton.data }, void 0)] }, void 0)); | ||
} }), (0, jsx_runtime_1.jsx)("span", { children: mySingleton.data })] })); | ||
}; | ||
const ReadComponent = () => ((0, jsx_runtime_1.jsx)("span", { children: (0, hooks_1.use)(MySingleton).data }, void 0)); | ||
const { queryAllByText, getByTestId, rerender } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {}, void 0)); | ||
const ReadComponent = () => ((0, jsx_runtime_1.jsx)("span", { children: (0, hooks_1.use)(MySingleton).data })); | ||
const { queryAllByText, getByTestId, rerender } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {})); | ||
expect(queryAllByText('initial').length).toBe(2); | ||
expect(queryAllByText('loaded data').length).toBe(0); | ||
yield (0, react_1.act)(() => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { | ||
yield (0, react_1.act)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
react_1.fireEvent.click(getByTestId(buttonId)); | ||
})); | ||
rerender((0, jsx_runtime_1.jsx)(RootComponent, {}, void 0)); | ||
rerender((0, jsx_runtime_1.jsx)(RootComponent, {})); | ||
expect(queryAllByText('initial').length).toBe(0); | ||
expect(queryAllByText('loaded data').length).toBe(2); | ||
done(); | ||
})); | ||
test('stateful', (done) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { | ||
test('stateful', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
let MyStateful = class MyStateful { | ||
@@ -156,3 +159,3 @@ constructor() { | ||
}; | ||
MyStateful = (0, tslib_1.__decorate)([ | ||
MyStateful = tslib_1.__decorate([ | ||
decorators_1.stateful | ||
@@ -168,3 +171,3 @@ ], MyStateful); | ||
const RootComponent = () => { | ||
return ((0, jsx_runtime_1.jsxs)(Provider_1.Provider, Object.assign({ dependencies: dependencies }, { children: [(0, jsx_runtime_1.jsx)(LoadComponent, { message: firstMessage, buttonId: button1 }, void 0), (0, jsx_runtime_1.jsx)(ReadComponent, {}, void 0), (0, jsx_runtime_1.jsxs)(Provider_1.Provider, Object.assign({ dependencies: dependencies }, { children: [(0, jsx_runtime_1.jsx)(LoadComponent, { message: secondMessage, buttonId: button2 }, void 0), (0, jsx_runtime_1.jsx)(ReadComponent, {}, void 0)] }), void 0)] }), void 0)); | ||
return ((0, jsx_runtime_1.jsxs)(Provider_1.Provider, Object.assign({ dependencies: dependencies }, { children: [(0, jsx_runtime_1.jsx)(LoadComponent, { message: firstMessage, buttonId: button1 }), (0, jsx_runtime_1.jsx)(ReadComponent, {}), (0, jsx_runtime_1.jsxs)(Provider_1.Provider, Object.assign({ dependencies: dependencies }, { children: [(0, jsx_runtime_1.jsx)(LoadComponent, { message: secondMessage, buttonId: button2 }), (0, jsx_runtime_1.jsx)(ReadComponent, {})] }))] }))); | ||
}; | ||
@@ -175,9 +178,9 @@ const LoadComponent = ({ message, buttonId }) => { | ||
myStateful.message = message; | ||
} }, void 0) }, void 0)); | ||
} }) })); | ||
}; | ||
const ReadComponent = () => { | ||
const myStateful = (0, hooks_1.use)(MyStateful); | ||
return ((0, jsx_runtime_1.jsx)("span", { children: myStateful.message }, void 0)); | ||
return ((0, jsx_runtime_1.jsx)("span", { children: myStateful.message })); | ||
}; | ||
const { queryAllByText, getByTestId, rerender } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {}, void 0)); | ||
const { queryAllByText, getByTestId, rerender } = (0, react_1.render)((0, jsx_runtime_1.jsx)(RootComponent, {})); | ||
expect(queryAllByText('initial').length).toBe(2); | ||
@@ -187,6 +190,6 @@ expect(queryAllByText(firstMessage).length).toBe(0); | ||
// first state | ||
yield (0, react_1.act)(() => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { | ||
yield (0, react_1.act)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
react_1.fireEvent.click(getByTestId(button1)); | ||
})); | ||
rerender((0, jsx_runtime_1.jsx)(RootComponent, {}, void 0)); | ||
rerender((0, jsx_runtime_1.jsx)(RootComponent, {})); | ||
expect(queryAllByText('initial').length).toBe(1); | ||
@@ -196,12 +199,11 @@ expect(queryAllByText(firstMessage).length).toBe(1); | ||
// second state | ||
yield (0, react_1.act)(() => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { | ||
yield (0, react_1.act)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
react_1.fireEvent.click(getByTestId(button2)); | ||
})); | ||
rerender((0, jsx_runtime_1.jsx)(RootComponent, {}, void 0)); | ||
rerender((0, jsx_runtime_1.jsx)(RootComponent, {})); | ||
expect(queryAllByText('initial').length).toBe(0); | ||
expect(queryAllByText(firstMessage).length).toBe(1); | ||
expect(queryAllByText(secondMessage).length).toBe(1); | ||
done(); | ||
})); | ||
test('nested singletons', (done) => { | ||
test('nested singletons', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
let Service1 = class Service1 { | ||
@@ -212,3 +214,3 @@ constructor() { | ||
}; | ||
Service1 = (0, tslib_1.__decorate)([ | ||
Service1 = tslib_1.__decorate([ | ||
cheap_di_1.singleton | ||
@@ -221,3 +223,3 @@ ], Service1); | ||
}; | ||
Service2 = (0, tslib_1.__decorate)([ | ||
Service2 = tslib_1.__decorate([ | ||
cheap_di_1.singleton | ||
@@ -230,6 +232,6 @@ ], Service2); | ||
}; | ||
Service3 = (0, tslib_1.__decorate)([ | ||
Service3 = tslib_1.__decorate([ | ||
cheap_di_1.singleton | ||
], Service3); | ||
const buttonId = 'my-button'; | ||
const buttonId = 'my-button-3'; | ||
const TestComponent = () => { | ||
@@ -241,6 +243,6 @@ const s1 = (0, hooks_1.use)(Service1); | ||
s3.state = '000'; | ||
} }, { children: "update s3 state" }), void 0), (0, jsx_runtime_1.jsx)("p", { children: s1.state }, void 0), (0, jsx_runtime_1.jsx)("p", { children: s2.state }, void 0), (0, jsx_runtime_1.jsx)("p", { children: s3.state }, void 0)] }, void 0)); | ||
} }, { children: "update s3 state" })), (0, jsx_runtime_1.jsx)("p", { children: s1.state }), (0, jsx_runtime_1.jsx)("p", { children: s2.state }), (0, jsx_runtime_1.jsx)("p", { children: s3.state })] })); | ||
}; | ||
const Component = () => ((0, jsx_runtime_1.jsx)(SelfOneTimeProvider_1.SelfOneTimeProvider, Object.assign({ dependencies: [Service1] }, { children: (0, jsx_runtime_1.jsx)(SelfOneTimeProvider_1.SelfOneTimeProvider, Object.assign({ dependencies: [Service2] }, { children: (0, jsx_runtime_1.jsx)(SelfOneTimeProvider_1.SelfOneTimeProvider, Object.assign({ dependencies: [Service3] }, { children: (0, jsx_runtime_1.jsx)(TestComponent, {}, void 0) }), void 0) }), void 0) }), void 0)); | ||
const { rerender, getByTestId, queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Component, {}, void 0)); | ||
const Component = () => ((0, jsx_runtime_1.jsx)(SelfOneTimeProvider_1.SelfOneTimeProvider, Object.assign({ dependencies: [Service1] }, { children: (0, jsx_runtime_1.jsx)(SelfOneTimeProvider_1.SelfOneTimeProvider, Object.assign({ dependencies: [Service2] }, { children: (0, jsx_runtime_1.jsx)(SelfOneTimeProvider_1.SelfOneTimeProvider, Object.assign({ dependencies: [Service3] }, { children: (0, jsx_runtime_1.jsx)(TestComponent, {}) })) })) }))); | ||
const { rerender, getByTestId, queryByText } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Component, {})); | ||
expect(queryByText('123')).toBeInTheDocument(); | ||
@@ -250,13 +252,12 @@ expect(queryByText('456')).toBeInTheDocument(); | ||
expect(queryByText('000')).toBeNull(); | ||
react_1.fireEvent.click(getByTestId(buttonId)); | ||
rerender((0, jsx_runtime_1.jsx)(Component, {}, void 0)); | ||
setTimeout(() => { | ||
expect(queryByText('123')).toBeInTheDocument(); | ||
expect(queryByText('456')).toBeInTheDocument(); | ||
expect(queryByText('789')).toBeNull(); | ||
expect(queryByText('000')).toBeInTheDocument(); | ||
done(); | ||
}); | ||
}); | ||
yield (0, react_1.act)(() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
react_1.fireEvent.click(getByTestId(buttonId)); | ||
})); | ||
rerender((0, jsx_runtime_1.jsx)(Component, {})); | ||
expect(queryByText('123')).toBeInTheDocument(); | ||
expect(queryByText('456')).toBeInTheDocument(); | ||
expect(queryByText('789')).toBeNull(); | ||
expect(queryByText('000')).toBeInTheDocument(); | ||
})); | ||
}); | ||
//# sourceMappingURL=Provider.test.js.map |
@@ -9,7 +9,7 @@ "use strict"; | ||
const SelfOneTimeProvider = props => { | ||
const { dependencies, children } = props, rest = (0, tslib_1.__rest)(props, ["dependencies", "children"]); | ||
const { dependencies, children } = props, rest = tslib_1.__rest(props, ["dependencies", "children"]); | ||
const registrations = (0, react_1.useMemo)(() => dependencies, []); | ||
return ((0, jsx_runtime_1.jsx)(SelfProvider_1.SelfProvider, Object.assign({ dependencies: registrations }, rest, { children: children }), void 0)); | ||
return ((0, jsx_runtime_1.jsx)(SelfProvider_1.SelfProvider, Object.assign({ dependencies: registrations }, rest, { children: children }))); | ||
}; | ||
exports.SelfOneTimeProvider = SelfOneTimeProvider; | ||
//# sourceMappingURL=SelfOneTimeProvider.js.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
const SelfProvider = props => { | ||
const { dependencies, children } = props, rest = (0, tslib_1.__rest)(props, ["dependencies", "children"]); | ||
const { dependencies, children } = props, rest = tslib_1.__rest(props, ["dependencies", "children"]); | ||
const [registrationFunctions, setRegistrationFunctions] = (0, react_1.useState)(() => dependencies.map(mapper)); | ||
@@ -17,5 +17,5 @@ (0, react_1.useEffect)(() => { | ||
}, [dependencies]); | ||
return ((0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: registrationFunctions }, rest, { children: children }), void 0)); | ||
return ((0, jsx_runtime_1.jsx)(Provider_1.Provider, Object.assign({ dependencies: registrationFunctions }, rest, { children: children }))); | ||
}; | ||
exports.SelfProvider = SelfProvider; | ||
//# sourceMappingURL=SelfProvider.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
(0, tslib_1.__exportStar)(require("./InternalLogger"), exports); | ||
(0, tslib_1.__exportStar)(require("./reconfigureObject"), exports); | ||
tslib_1.__exportStar(require("./InternalLogger"), exports); | ||
tslib_1.__exportStar(require("./reconfigureObject"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "cheap-di-react", | ||
"version": "3.2.1", | ||
"version": "3.2.2", | ||
"description": "", | ||
@@ -10,10 +10,14 @@ "scripts": { | ||
"devDependencies": { | ||
"@types/jest": "26.0.23", | ||
"@types/react": "17.0.6", | ||
"jest": "26.6.3", | ||
"@testing-library/jest-dom": "5.14.1", | ||
"@testing-library/react": "12.0.0", | ||
"ts-jest": "26.5.6", | ||
"tslib": "2.2.0", | ||
"typescript": "4.4.2" | ||
"@testing-library/jest-dom": "5.16.4", | ||
"@testing-library/react": "13.3.0", | ||
"@types/jest": "28.1.1", | ||
"@types/react": "18.0.12", | ||
"jest": "28.1.1", | ||
"jest-environment-jsdom": "28.1.1", | ||
"ts-jest": "28.0.4", | ||
"tslib": "2.4.0", | ||
"typescript": "4.7.3", | ||
"cheap-di": "3.2.1", | ||
"react": "18.1.0", | ||
"react-dom": "18.1.0" | ||
}, | ||
@@ -20,0 +24,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67448
12
63
767