New answers tagged

2

You might notice that createChildren is almost the same as MyTree -- the only difference is that createChildren takes its argument directly instead of as a props object. So with a small change we can remove createChildren entirely: const MyTreeNestedItems = (props) => { const { data } = props; let children = null; if (data.children.length) { ...


2

Use function syntax/memo when possible Use destructuring Use object literal shorthand Define defaults for width and height handleClick is just onClick renamed Use tooling for formatting your code (eslint, prettier) Prefer ternary over if (not always true) Have a well defined API for your components (ListElement needs text, not the entire item, and doesn't ...


0

So here's what I've ended up doing: INITIAL_VALUES.js function GET_FEATURE_TYPES_INITIAL_VALUES() { const FEATURE_TYPE_INITIAL_VALUES = { SINGLE_CHOICE: '', MULTIPLE_CHOICE: [], BOOLEAN: false, NUMBER: 0, STRING: '' }; return FEATURE_TYPE_INITIAL_VALUES; } function GET_FILTER_TYPES_INITIAL_VALUES() { const ...


2

Using Array.join is unrelated to usage of async and await. Also note that the time it takes to call Array.join is insignificant in comparison to the time it takes to make the two API calls. You can consider call1().then(data => call2(data)) roughly equivalent to const data = await call1(); call2(data). There's no (obvious) performance gain to be made ...


0

Reviewing your current app Nice work so far! Calculators make educational projects because you can incrementally scale up the complexity. As the application grows, numerous design decisions in maintaining expression state need to be made and interesting parsing and equation evaluation situations arise. Here are some thoughts on the current code: Typo ...


Top 50 recent answers are included