local I=require(script.Parent.Component)local X=I:extend("\080\117\114\101\067\111\109\112\111\110\101\110\116")X.extend=I.extend function X.shouldUpdate(Z,I,X)if X~=Z.state then return true end if I==Z.props then return false end for I,X in pairs(I)do if Z.props[I]~=X then return true end end for X,Z in pairs(Z.props)do if I[X]~=Z then return true end end return false end return X
--[[
	A version of Component with a `shouldUpdate` method that forces the
	resulting component to be pure.
]]

local Component = require(script.Parent.Component)

local PureComponent = Component:extend("PureComponent")

-- When extend()ing a component, you don't get an extend method.
-- This is to promote composition over inheritance.
-- PureComponent is an exception to this rule.
PureComponent.extend = Component.extend

function PureComponent:shouldUpdate(newProps, newState)
	-- In a vast majority of cases, if state updated, something has updated.
	-- We don't bother checking in this case.
	if newState ~= self.state then
		return true
	end

	if newProps == self.props then
		return false
	end

	for key, value in pairs(newProps) do
		if self.props[key] ~= value then
			return true
		end
	end

	for key, value in pairs(self.props) do
		if newProps[key] ~= value then
			return true
		end
	end

	return false
end

return PureComponent
