mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-12-01 22:13:54 +03:00
Added ability to display function name as actionType
The normal advice is that `actionType` should be a string. This is purely for debugging purposes. If the tools used for debugging are altered, then it would be easier to use something other than a string. Using a function means you don't have to have a separate action variable from the action creator itself: ```js some someActionCreator = () => ({ type: someActionCreator, }) ``` Redux doesn't care if your action type is a string, object, symbol or whatever. Even @gaearon noted it should be a Symbol for uniqueness, but only said to use strings because of the debugging potential. Another benefit of using functions is you're only comparing memory references rather than strings. This is a performance boost, but probably not one that will manifest in most applications. We could even take this further to include `symbol.description` and `classInstance.constructor.name`. The one downfall is most Redux tooling both utilizes and expects strings. This would need to change. Even `createReducer` would need to take a `Map` of actions instead of an `Object` or this wouldn't work.
This commit is contained in:
parent
03d1448dc3
commit
62957d2472
|
@ -76,7 +76,11 @@ export default class ActionListRow extends Component {
|
||||||
isSkipped && 'actionListItemNameSkipped'
|
isSkipped && 'actionListItemNameSkipped'
|
||||||
])}
|
])}
|
||||||
>
|
>
|
||||||
{actionType}
|
{
|
||||||
|
typeof actionType === 'function'
|
||||||
|
? actionType.name
|
||||||
|
: actionType
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
{hideActionButtons ? (
|
{hideActionButtons ? (
|
||||||
<RightSlider styling={styling} shown>
|
<RightSlider styling={styling} shown>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user