0

I'm guessing, when my component start to grow big and has some complex logic in his functions, should I make a separated file for functions and handlers? Or its a better practice to maintain the component logic and render method in the same file?

Sorry if its not a good question, but this bother me. I hope to get some good tip. Thank you.

Mohamed Ibrahim Elsayed
  • 2,734
  • 3
  • 23
  • 43
atom-100
  • 1
  • 1

2 Answers2

0

Rather than writing a complex component, define at most smallest part for the component. This way, you'll have only required hooks and methods. So that you'll have clear vision on your way.

For eg.

Bad

  • Face Component

Good

  • Eye Component
  • Mouth Component
  • Nose Component
  • Ear Component
  • ... Component

You may also read the following docs:

And most importantly:

Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231
0

The React site provides a great overview about Thinking in React that walks you through the thought process of building a searchable product data table using React.

I suggest starting there then looking through the whole Main Concepts section.

Building a scalable, well architected application takes experience. Not something you can glean from one stackoverflow question. Best of luck!

bflemi3
  • 6,698
  • 20
  • 88
  • 155