[IMP] store: display error if no store found

This commit is contained in:
Géry Debongnie
2019-11-03 23:54:54 +01:00
committed by aab-odoo
parent 8d1dd06340
commit b211e75140
2 changed files with 19 additions and 0 deletions
+3
View File
@@ -84,6 +84,9 @@ const isStrictEqual = (a, b) => a === b;
export function useStore(selector, options: SelectorOptions = {}): any {
const component: Component<any, any> = Component.current!;
const store = options.store || (component.env.store as Store);
if (!(store instanceof Store)) {
throw new Error(`No store found when connecting '${component.constructor.name}'`);
}
let result = selector(store.state, component.props);
const hashFn = store.observer.revNumber.bind(store.observer);
let revNumber = hashFn(result) || result;