Skip to content

Commit

Permalink
Add: child container ref changing on parent change
Browse files Browse the repository at this point in the history
Merge pull request #30 from BerkliumBirb/main
  • Loading branch information
vovaspace authored Feb 6, 2023
2 parents b5115b7 + a554a68 commit 570c4bd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/brandi-react/src/container/ContainerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ export const ContainerProvider: React.FunctionComponent<{
isolated?: boolean;
}> = ({ children, container, isolated = false }) => {
const parentContainer = useContainer(false);
const clonedContainer = React.useMemo(() => container.clone(), [container]);

if (!isolated) clonedContainer.extend(parentContainer);
const extend = !isolated ? parentContainer : null;

const clonedContainer = React.useMemo(() => {
const cloned = container.clone()
if (extend) cloned.extend(extend)
return cloned
}, [container, extend]);


return (
<ContainerContext.Provider value={clonedContainer}>
Expand Down

0 comments on commit 570c4bd

Please sign in to comment.