Skip to content

Commit

Permalink
Merge pull request facebook#311 from darknoon/fix-memoize-with-no-mem…
Browse files Browse the repository at this point in the history
…oizer

Fix layout bug where you didn't setup the memoizer
  • Loading branch information
darknoon committed Jul 20, 2015
2 parents 246fe33 + 38227b9 commit 951260d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ComponentKit/Core/CKComponentMemoizer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ id CKMemoize(CKMemoizationKey memoizationKey, id (^block)(void))
CKComponentLayout CKMemoizeOrComputeLayout(CKComponent *component, CKSizeRange constrainedSize, const CKComponentSize& size, CGSize parentSize)
{
if (component && [component shouldMemoizeLayout]) {
return [[_CKComponentMemoizerImpl currentMemoizer] cachedLayout:component thatFits:constrainedSize restrictedToSize:size parentSize:parentSize];
} else {
return [component computeLayoutThatFits:constrainedSize restrictedToSize:size relativeToParentSize:parentSize];
_CKComponentMemoizerImpl *impl = [_CKComponentMemoizerImpl currentMemoizer];
if (impl) { // If component wants layout memoization but there isn't a current memoizer, fall down to compute case
return [impl cachedLayout:component thatFits:constrainedSize restrictedToSize:size parentSize:parentSize];
}
}
return [component computeLayoutThatFits:constrainedSize restrictedToSize:size relativeToParentSize:parentSize];
}

0 comments on commit 951260d

Please sign in to comment.