From 015b6c526dcac2054f048f2330f5f2828862e847 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Sat, 5 Oct 2013 14:35:03 -0400 Subject: [PATCH] shrink working on props in state entry --- cookbook/cb-10-props-in-getInitialSate-as-anti-pattern-tip.md | 4 ++-- cookbook/cb-10-props-in-getInitialSate-as-anti-pattern.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cookbook/cb-10-props-in-getInitialSate-as-anti-pattern-tip.md b/cookbook/cb-10-props-in-getInitialSate-as-anti-pattern-tip.md index 68358537..6d8b89c3 100644 --- a/cookbook/cb-10-props-in-getInitialSate-as-anti-pattern-tip.md +++ b/cookbook/cb-10-props-in-getInitialSate-as-anti-pattern-tip.md @@ -7,7 +7,7 @@ permalink: props-in-getInitialSate-as-anti-pattern-tip.html > Note: > -> This is not really a React-specific tip, as such anti-patterns often occur in code in general; in this case, React simply points them out more clearly. +> This isn't really a React-specific tip, as such anti-patterns often occur in code in general; in this case, React simply points them out more clearly. Using props, passed down from parent, to generate state in `getInitialState` often leads to duplication of "source of truth", i.e. where the real data is. Whenever possible, compute values on-the-fly to ensure that they don't get out of sync later on and cause maintenance trouble. @@ -42,7 +42,7 @@ var MessageBox = React.createClass({ React.renderComponent(, mountNode); ``` -Also works, for larger logic: +For more complex logic: ```js /** @jsx React.DOM */ diff --git a/cookbook/cb-10-props-in-getInitialSate-as-anti-pattern.md b/cookbook/cb-10-props-in-getInitialSate-as-anti-pattern.md index fab72467..b26027aa 100644 --- a/cookbook/cb-10-props-in-getInitialSate-as-anti-pattern.md +++ b/cookbook/cb-10-props-in-getInitialSate-as-anti-pattern.md @@ -38,7 +38,7 @@ var MessageBox = React.createClass({ React.renderComponent(, mountNode); ``` -Or, if the logic's big, isolate it so: +For more complex logic: ```js /** @jsx React.DOM */ @@ -56,6 +56,6 @@ React.renderComponent(, mountNode); ``` ### Discussion -This is not really a React-specific tip, as such anti-patterns often occur in code in general; in this case, React simply points them out more clearly. +This isn't really a React-specific tip, as such anti-patterns often occur in code in general; in this case, React simply points them out more clearly. Using props, passed down from parent, to generate state often leads to duplication of "source of truth", i.e. where the real data is. Whenever possible, compute values on-the-fly to ensure that they don't get out of sync later on and cause maintenance trouble.