Hi,
I am trying to configure state in my app. Following the docs almost exactly results in the following error after building:
Uncaught TypeError: e.map is not a function
This is using the latest beta 13 version
This is my main.ts where I register state:
import Aurelia from 'aurelia';
import { StateDefaultConfiguration } from '@aurelia/state';
import { DialogDefaultConfiguration } from '@aurelia/dialog';
import {initialState} from "./state/initialstate";
import {movieHandler} from "./state/action-handlers";
import { App } from './app';
import * as Components from './components';
Aurelia
.register(DialogDefaultConfiguration)
.register(
StateDefaultConfiguration.init(
initialState,
movieHandler
)
)
.register(Components)
.app(App)
.start();
In the docs is says I should have the movieHandler in an Array like this:
StateDefaultConfiguration.init(
initialState,
[movieHandler]
)
but that does not compile. Results in an " No overload matches this call" error. My IDE also highlights it as an error, removing the brackets compiles ok, but gives the the runtime error e.map is not a function.
This is my handler, almost identical to the docs version:
export function movieHandler(currentState, action) {
return action.type === 'openMovie' ? { ...currentState, currentMovie: action.value } : currentState;
}
Any help would be appreciated. Thanks in advance.
edit: I need to be more specific. Everything is working when I am running the app in “debug” mode, with the start script. Its builds without error, but when trying to run in the browser the app crashes with the error above. When I remove the state configuration, everything works again.