This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Design Challenge 002: Simplifying State Management in React | |
| // https://juntao.substack.com/p/design-challenge-002-simplifying | |
| const ApprovalPanel = ({id}) => { | |
| const [isDone, setDone] = useState(false); | |
| const handleApprove = () => { | |
| fetch('POST', `/rest/approval/${id}/approve`) | |
| .then(r => r.json()) | |
| .then(data => setDone(data.isDone)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Team { | |
| constructor(members) { | |
| this._members = members; | |
| } | |
| get members() { | |
| return this._members; | |
| } | |
| set members(members) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Your challenge is to find ways to simplify this code further. | |
| // You can use any patterns or refactoring techniques you find useful. | |
| // Think about improving readability and maintainability while ensuring the | |
| // functionality remains intact. | |
| // Backend response | |
| { | |
| "operations": [ | |
| { |
OlderNewer