Skip to content

Commit

Permalink
fix: new container for REQUEST scope
Browse files Browse the repository at this point in the history
  • Loading branch information
foreleven authored and JounQin committed Aug 19, 2019
1 parent 987a70e commit 8697e6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stated-bean",
"version": "0.1.2-alpha.1",
"version": "0.1.2-alpha.2",
"repository": "[email protected]:mjolnirjs/stated-bean.git",
"license": "MIT",
"main": "dist/cjs",
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/useStatedBean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ export function useStatedBean<T extends ClassType>(

if (option.scope === StatedBeanScope.CONTEXT) {
container = context.container;
} else if (option.scope === StatedBeanScope.REQUEST) {
container = new StatedBeanContainer();
container.register(type);
} else {
container = context.container || new StatedBeanContainer();
container.register(type);
}

return container;
}, [option.scope, context.container, type]);
const [container, setContainer] = useState<StatedBeanContainer | undefined>(
Expand Down

0 comments on commit 8697e6c

Please sign in to comment.