mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 10:42:12 +00:00
check for the type of map
This commit is contained in:
parent
e14896deb0
commit
ec43557dd8
1 changed files with 6 additions and 1 deletions
|
|
@ -24,7 +24,12 @@ const useModelState = ({ init, action, ...args }) => {
|
|||
}, []);
|
||||
React.useLayoutEffect(() => {
|
||||
const onNewStateThrottled = throttle(() => {
|
||||
setState(map(core.transport.getState(model)));
|
||||
const state = core.transport.getState(model);
|
||||
if (typeof map === 'function') {
|
||||
setState(map(state));
|
||||
} else {
|
||||
setState(state);
|
||||
}
|
||||
}, timeout);
|
||||
if (routeFocused) {
|
||||
core.transport.on('NewState', onNewStateThrottled);
|
||||
|
|
|
|||
Loading…
Reference in a new issue