109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/react/component/class_methods.rb', line 109
def export_state(*states, &block)
deprecation_warning "'export_state' is deprecated. Use the 'state' macro to declare states."
default_initial_value = (block && block.arity == 0) ? yield : nil
states_hash = (states.last.is_a?(Hash)) ? states.pop : {}
states.each { |name| states_hash[name] = default_initial_value }
states_hash.each do |name, value|
state(name => value, scope: :class, reader: true)
singleton_class.define_method("#{name}!") do |*args|
mutate.__send__(name, *args)
end
end
end
|