FAQ
Table of Contents
Where can I get help using redux-undo
?
redux-undo
?To get an understanding of the basics, read through the README and checkout some examples.
To get help with a specific use case, see if there is already an example in these docs or the examples. If not, ask for help in the gitter chat!
If it seems you have found a bug or you are itching for a new feature, go ahead and submit it as an issue following the template provided. Please reserve Github issues for bugs and features only. Ask any other questions on the gitter chat and someone will probably be able to help you with your problem.
Where can I find examples of how to use redux-undo
?
redux-undo
?Look at the examples/
directory of the project folder. The todos-with-undo/
is a good project to start messing with.
Just open http://localhost:3000 and you are good to go!
How do I prevent cluttering up history with rapidly changing state?
The throttled-drag/
project found the examples/
directory gives a good demonstration of how to debounce undos (the filter is in util/undoFilter.js
).
This general question has different solutions depending on your exact problem. Let's say you have one or more rapidly dispatched actions, for example MOVE_CURSOR
and UPDATE_OBJECT_POS
, that ends with a lone action PLACE_OBJECT
, and you only want to record the end state after PLACE_OBJECT
. Then you can simply use a filter excludeAction(['MOVE_CURSOR', 'UPDATE_OBJECT_POS'])
For more complex requirements, consider writing your own custom filter.
Can I have multiple, separate undoable functions?
Yes you can! Simply wrap each reducer with its own undoable()
.
Do not forget to setup different undo/redo types to undo/redo each slice separately.
If you wish to have a single conglomerate history that a user can undo one action at a time, you can wrap the root reducer with undoable()
.
You probably need to use custom filters and/or groupBy
to undo/redo in reasonable chunks.
Why are my actions not being filtered?
If you are trying to prevent actions from changing state, that is not what filter
is for. The filter
option only prevents state changes from becoming part of the history, i.e. the new state being pushed into state.past
. If you need this functionality, check out redux-ignore.
On the other hand, here is how to use the helper functions:
When writing a custom filter, return true
for actions that you want to keep in history.
What is _latestUnfiltered
? Can I remove it?
_latestUnfiltered
? Can I remove it?What is it?
State wrapped by undoable()
contains the field _latestUnfiltered
alongside past
, present
, etc. This field is used to keep track of state that should be put in the history but cannot yet because the previous action(s) were filtered. It is basically a temporary variable between filtered actions.
Can I remove it?
Short answer, no. It is an integral part of filtering actions from history and cannot be removed from the library. You can ignore it completely, but overriding/removing it may have unwanted consequences.
While there is a tad more overhead handling actions in the reducer, it is necessary with the current setup. In the future, there might be optimization that makes this field less burdensome for users that do not use the filtering functionality.
Why am I getting Cannot find module 'redux-undo'
?
Cannot find module 'redux-undo'
?If you are using redux-undo in a CommonJS or UMD environment, you need to add .default
to your imports.
ES6 imports should work without a hitch.
If this fixed your issue, you might also want to checkout how to upgrade from 0.6 to 1.0.
Last updated