# Is this handled efficently? \*short code

**URL:** <https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413>\
**Category:** General\
**Created:** [July 15, 2016, 9:20am UTC](https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413 "2016-07-15T09:20:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nameToReachPeople](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/nametoreachpeople/32/10814_2.png) [@nameToReachPeople](https://forum.freecodecamp.org/u/nameToReachPeople)\
**Post date:** [July 15, 2016, 9:20am UTC](https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413/1 "2016-07-15T09:20:12Z")

</div>

pen: [[https://codepen.io/ustvarno/pen/oLBQzx](https://codepen.io/ustvarno/pen/oLBQzx) ]  
have two nodes and controller.  
in controller’ render i render this two nodes.  
with changing props for first node, it both get rerender.  
Is this handled efficently?

---

<div class="post-metadata">

**Author:** ![imtoobose](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/imtoobose/32/9914_2.png) [@imtoobose](https://forum.freecodecamp.org/u/imtoobose)\
**Post date:** [July 15, 2016, 11:06am UTC](https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413/2 "2016-07-15T11:06:28Z")

</div>

You seem to have the right idea. You should have as many stateless components as possible and use props for changing data for children. I would caution against taking this philosophy to an extreme though because it ends up in slightly cluttered code like my [game of life project](https://codepen.io/imtoobose/pen/QEgVQJ), which was my first attempt at react.

I ended up having only one (massive) component with state and it handled all changes to every element. Try to have few state components but make sure that every component has a well defined function and doesn’t do too much work on its own. To be honest though, I’m not sure if my implementation is effective in terms of performance but it’s better to have one parent with state than 2.4k children with it.

---

<div class="post-metadata">

**Author:** ![nameToReachPeople](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/nametoreachpeople/32/10814_2.png) [@nameToReachPeople](https://forum.freecodecamp.org/u/nameToReachPeople)\
**Post date:** [July 15, 2016, 11:42am UTC](https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413/3 "2016-07-15T11:42:51Z")

</div>

look at foot here [[https://codepen.io/ustvarno/pen/grGJGZ](https://codepen.io/ustvarno/pen/grGJGZ) ] 🙂  
i tried that effect of fade on :before element and it looks good in chrome, but in firefox, not so much

---

<div class="post-metadata">

**Author:** ![imtoobose](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/imtoobose/32/9914_2.png) [@imtoobose](https://forum.freecodecamp.org/u/imtoobose)\
**Post date:** [July 15, 2016, 12:34pm UTC](https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413/4 "2016-07-15T12:34:44Z")

</div>

Oh wow, I’m flattered I provided some inspiration 😁

As for your shadow in firefox, it seems to work fine for me? I also noticed my game of life is terribly slow on firefox (which I never really use). I really have to appreciate Chrome’s JS engine, and the need to refactor this project later on.

---

<div class="post-metadata">

**Author:** ![nameToReachPeople](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/nametoreachpeople/32/10814_2.png) [@nameToReachPeople](https://forum.freecodecamp.org/u/nameToReachPeople)\
**Post date:** [July 15, 2016, 1:04pm UTC](https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413/5 "2016-07-15T13:04:31Z")

</div>

🙂

my board architecture logic is based on this other link in footer, it is very simple and looks nice

---

<div class="post-metadata">

**Author:** ![nameToReachPeople](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/nametoreachpeople/32/10814_2.png) [@nameToReachPeople](https://forum.freecodecamp.org/u/nameToReachPeople)\
**Post date:** [July 16, 2016, 8:49pm UTC](https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413/6 "2016-07-16T20:49:55Z")

</div>

but if we are based on redux pattern for constructing react app, then all need to be stored on ‘head’ of application, and then to update own state for children props? How this can be seen as efficent pattern?

---

<div class="post-metadata">

**Author:** ![imtoobose](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/imtoobose/32/9914_2.png) [@imtoobose](https://forum.freecodecamp.org/u/imtoobose)\
**Post date:** [July 17, 2016, 6:54am UTC](https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413/7 "2016-07-17T06:54:17Z")

</div>

That’s something that confuses me too. As far as I understand, state re renders the component. So wouldn’t it be less efficient to have less stateful components? I need more experience with React to really give a decent answer. I’ll try re making the game of life with the cells having state and see if that works better.

---

<div class="post-metadata">

**Author:** ![nameToReachPeople](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/nametoreachpeople/32/10814_2.png) [@nameToReachPeople](https://forum.freecodecamp.org/u/nameToReachPeople)\
**Post date:** [July 17, 2016, 9:08am UTC](https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413/8 "2016-07-17T09:08:49Z")

</div>

maybe if u generate all cells from once in render then u got slowly render. But if u render just row in what event happend like click etc, then just rerender that row

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 3:48am UTC](https://forum.freecodecamp.org/t/is-this-handled-efficently-short-code/20413/9 "2021-01-16T03:48:06Z")

</div>

Closed on January 16, 2021, 3:48am UTC


