Hacker News new | past | comments | ask | show | jobs | submit login

One funny thing about React is that the most dangerous kind of developer is the one with middle-level knowledge of it

beginners don't know enough to do optimisation seniors know enough that they only optimise what is needed mid-level are capable of build code that needs to be optimised, but they tend to over-optimise and often do the optimisation wrong

for example what a mid-level might do:

const C1 = React.memo(({values}) => {...}) const C2 = () => { return <C1 values={[1,2,3]} /> }

That React.memo is useless because arrays and objects are mutable in JS It also reveals a flaw in JS/React in that memoization often needs to happen at the parent instead of the child, creating awkward code and implicit behaviour and implicit performance traps when forgetting to memoize object/array props that the child expect to be memoized. The child decides which props should be memoized, but doesn't enforce it and no amount of typescript will catch that problem

Fortunately there is a proposal that will fix this problem by introducing records and tuples like python (immutable objects/arrays) https://github.com/tc39/proposal-record-tuple but it still seems far off to being usable as I don't think it will be viable to polyfill it for browsers that don't support it




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: