L
L
LB7772015-03-25 17:25:29
React
LB777, 2015-03-25 17:25:29

Why are flux constants assigned null?

Constants created with "keyMirror" are set to null

var keyMirror = require('react/lib/keyMirror');

// Define action constants
module.exports = keyMirror({
  CART_ADD: null,
  CART_REMOVE: null,
  CART_VISIBLE: null,
  SET_SELECTED: null,
  RECEIVE_DATA: null
});

Unfortunately, I can’t understand, but I want to figure out why it assigns exactly null and whether these values ​​change during operation.
Explain please =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Antropov, 2015-03-25
@LB777

This function returns an object where all keys have the name of the key as their value, so this can be represented as

// Define action constants
module.exports = {
  CART_ADD: "CART_ADD",
  CART_REMOVE: "CART_REMOVE",
  CART_VISIBLE: "CART_VISIBLE",
  SET_SELECTED: "SET_SELECTED",
  RECEIVE_DATA: "RECEIVE_DATA"
};

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question