You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is kind of a subtle React philosophy thing, but you should generally be suspicious if your code ever has to touch the real DOM. React is designed to handle all DOM updates for you, so if you're ever doing a querySelector or directly changing classNames etc that's usually something to avoid.
Remember your component re-runs whenever state changes, which means you can put conditions and dynamic stuff into your JSX to determine e.g. what classNames elements should have. You just need to have state values that let you know what to render.
E.g. if you kept track of the selected cards in state you could then declaratively render your UI based on that state:
week10-AJ/src/components/play.js
Lines 21 to 28 in 4888b86
This is kind of a subtle React philosophy thing, but you should generally be suspicious if your code ever has to touch the real DOM. React is designed to handle all DOM updates for you, so if you're ever doing a querySelector or directly changing classNames etc that's usually something to avoid.
Remember your component re-runs whenever state changes, which means you can put conditions and dynamic stuff into your JSX to determine e.g. what classNames elements should have. You just need to have state values that let you know what to render.
E.g. if you kept track of the selected cards in state you could then declaratively render your UI based on that state:
The text was updated successfully, but these errors were encountered: