Closed 40thieves closed 5 years ago
My only concern about removing completely constructor() is that students may see a lot of examples on the web including the official documentation on React which uses constructor and may be clueless about this if we never introduce it. If using the class syntax, I feel overall we see more often React components written using constructor than without.
My only concern about removing completely constructor() is that students may see a lot of examples on the web
Right. I also have this concern (actually if I could control what students were looking at, then we'd teach class components first - less context switching).
I would say that we did "waste" about 20 - 30 mins of class in London talking about class inheritance, which imo is not particularly efficient use of time (especially with Hooks, and the need for classes going away).
Perhaps we could add a short section explaining what the state class property does, and explain it with the use of a constructor
?
including the official documentation on React
That is a good point.
I'll also get this rebased
@llh1 Was discussing this with Neill from London earlier today. To push this over the line I'm happy to revert the constructor
change if you're still against it. I'd like to try switching over to Hooks for our next class anyway, which makes classes somewhat redundant.
@40thieves Yes if you don't mind, i'd prefer to keep constructor for now as i think it's still more straightforward to explain just one way of doing things aligned with the documentation available on the web. But let's keep the discussion open on this, I'll pay attention of the students' response to this in few weeks in Glasgow and I'll let you know about it.
@llh1 I've pushed revert for the constructor
changes (and fixed a missing super(props)
call I spotted). Are you happy with this approach?
@40thieves That's great :) thanks!
A few minor changes to the React module, based on feedback from teaching London class 5. Summary of the changes:
constructor
from examples/exercises with state initialisation. We found that this only added confusion. We ended up having to talk about class inheritance for a while, which a) doesn't help much with React understanding and b) isn't really what React uses classes for - classes are treated more like mixins. (I haven't updated the CodeSandboxes yet, but I can do that easily once this is merged)null
in render instead of confusingly named component (IsShown
/IsNotShown
)I'm aware that this may have some conflicts with @llh1's PR, but happy to get that merged first and can then deal with the conflicts.