In the second file below I am trying to figure out what [CALL_API]
is. What do the brackets mean? Is [CALL_API]
the key for the object or is [CALL_API]
resolved to something that is the actual key? And what is the purpose of doing it this way instead of using the string "CALL_API" as the key?
// file: middlewares/api.js
export const CALL_API = Symbol('CALL_API');
// (rest of file ommitted)
-
import { CALL_API } from 'middlewares/api';
store.dispatch({
[CALL_API]: {
method: 'get',
path: '/questions',
sendingType: 'SENDING_QUESTIONS',
successType: 'LOAD_QUESTIONS_SUCCESS',
}
});
This code was from a react-redux app. More of the context can be seen is this pluker.