Skip to content

Frozen actions

Choose a tag to compare

@franciscop franciscop released this 09 Jul 14:54
· 233 commits to master since this release

Added a better implementation of useActions() that can also access nested properties:

// Before:
const setUser = useActions('user');
const setName = name =>  setUser(user => ({ ...user, name }));

// After:
const setName = useActions('user.name');

Added freezing (and its associated testing) so that we cannot accidentally mutate existing properties:

// Before:
const user = useSelector('user');
user.id = 10;  // Seems to work; leads to bugs

// After:
const user = useSelector('user');
user.id = 10;  // Throws an explicit error