JavaScript The right React Component PropTypes for es6 (Weak) Maps, Sets

I want to force the user to pass an es6 Map object to a React component using PropTypes, like this for example:

static propTypes = {
  elementsMap: React.PropTypes.map(React.PropTypes.string, editorPropTypes.element).isRequired,
}

But looks like there is nothing like this in React. (The official documentation).

Answer:1
elementsMap: p.instanceOf(Map).isRequired
Answer:2

It's not convenient, but it's possible to write your own PropType.

From React's source (which it unfortunately does not expose at this point):

function createChainableTypeChecker(validate) {
  function checkType(isRequired, props, propName, componentName, location, propFullName) {
    componentName = componentName || ANONYMOUS;
    propFullName = propFullName || propName;
    if (props[propName] == null) {
      var locationName = ReactPropTypeLocationNames[location];
      if (isRequired) {
        return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.'));
      }
      return null;
    } else {
      return validate(props, propName, componentName, location, propFullName);
    }
  }

  var chainedCheckType = checkType.bind(null, false);
  chainedCheckType.isRequired = checkType.bind(null, true);

  return chainedCheckType;
}

Which you can use like so:

const map = createChainableTypeChecker(function(props, propName, componentName, location, propFullName) {
    if (...) {
        return null; // pass the check
    }
    return new Error('Error message'); // fail the check
});
Answer:3

I see decorators being used today already in some javascript code. My question is really two fold. First: If decorators have not even been finalized how is it possible to use them in production code,...

I see decorators being used today already in some javascript code. My question is really two fold. First: If decorators have not even been finalized how is it possible to use them in production code,...

I'm totally new to eslint configurations. I'm using tslint for typescript for quite a while now so I'm familiar with the concept. eslint uses for many rules a syntax like "no-cond-assign": [2, "...

I'm totally new to eslint configurations. I'm using tslint for typescript for quite a while now so I'm familiar with the concept. eslint uses for many rules a syntax like "no-cond-assign": [2, "...

I have some problem when I try to upsert my object with new ones(parsed from xml file),but I got the following error: MongoError: exception: After applying the update to the document {_id: ObjectId(...

I have some problem when I try to upsert my object with new ones(parsed from xml file),but I got the following error: MongoError: exception: After applying the update to the document {_id: ObjectId(...

Our website is currently using jQuery library and getting a traffic of about 1 million monthly. We want to include API centric approach, so decided to move to Javascript MVC and have chosen angularJS ...

Our website is currently using jQuery library and getting a traffic of about 1 million monthly. We want to include API centric approach, so decided to move to Javascript MVC and have chosen angularJS ...