reactjs / reactjs/react.dev

We have hooks, then still do we use Container components and Presentational components?

Ouverte
#2,819 0 commentaires 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

discussion
Langage dominant
JavaScript
Étoiles
11.8k
Forks
7.9k
Merge moyen
1 j 11 h
PR mergées (30 j)
11

Description

I think it is a bit confusing and maybe a doc or writing can explain the situation.

After we have hooks, do we still design our app into Container components and Presentational components? (Does it mean we should not divide up our app design into containers and presentational components?)

Or does it simply mean: in the past we use class components as containers with states, and function components as presentation components, and now we can use function components as both containers and presentational components, and the recommendation is still to divide our app design into containers and presentational component?

In the past, we can simply use class components ONLY and we could still divide our app design into containers and presentational components. So function component having state doesn't change that situation... the question is more like should we now still divide our app design into containers and presentational component? So nowadays we could still make container components using function components, and then, make presentational components and use function components to do that, and strictly do not use any hooks in them, because then they become stateful and therefore not just "presentational".

I think the short version of the question is: even with function components able to use states, should we still divide up our app into components that have states, and components that strictly do not have states and like "pure function" to present data?

@gaearon

https://stackoverflow.com/questions/60593403/for-reactjs-how-is-the-change-from-using-container-components-and-presentation

In the past, in ReactJS, one way was to divide our components into Container components and Presentational components, and even Dan Abramov wrote a note about it not any more the case if we can use Hooks now.

How should it be done now — how does Hooks solve the problem?

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Lisez le texte de l’issue ainsi que la question Stack Overflow liée et la note de Dan Abramov. Le travail est terminé lorsqu’une explication ciblée pour la documentation de React a été produite afin de répondre à la question de savoir si les Hooks modifient les recommandations concernant les composants container/presentational.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript, react
Domaine
documentation, frontend
Type d'issue
Documentation
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.