New answers tagged

1

This code looks good. There are only a couple improvements I would suggest. Loop over operations The code is somewhat repetitive for the operations, which goes against the Don't Repeat Yourself principle. Those operations could be added to an array and iterated over. You might have to get creative with calling functions but the operation functions could be ...


4

As a preface: Your code works good, is readable and does its job efficiently. The following review, though long, doesn't mean there is anything substantially wrong with it :-) General comments In the constructor, you're binding the event handlers to this. However, since you declare these event handlers as arrow functions, they are already bound to the ...


2

Test class In the scope of code you provided, the div is useless and may be omitted: render() { return this.state.comments.map((comment, index) => ( <Comment key={index} comment={comment}/> )) } However, as React warns you in the console, don't forget to pass a key prop to your array items (added in the snippet above). Comment class The ...


2

Rather than extract the Search input in to a different component I would suggest you keep the input and list in the same component. This way when printing the list you can highlight the search term directly. const HighlightableList = (props) => { const [searchTerm, setSearchTerm] = React.useState(""); const regex = new RegExp(searchTerm, "gi"); ...


Top 50 recent answers are included