Method: React::Component::ClassMethods#prop_types

Defined in:
lib/react/component/class_methods.rb

#prop_typesObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/react/component/class_methods.rb', line 49

def prop_types
  if self.validator
    {
      _componentValidator: %x{
        function(props, propName, componentName) {
          var errors = #{validator.validate(Hash.new(`props`))};
          return #{`errors`.count > 0 ? `new Error(#{"In component `#{name}`\n" + `errors`.join("\n")})` : `undefined`};
        }
      }
    }
  else
    {}
  end
end