Closed zarasyversen closed 5 years ago
If your React component’s render() function renders the same result given the same props and state, you can use React.PureComponent for a performance boost in some cases.
source: https://reactjs.org/docs/react-api.html#reactpurecomponent
Use shouldComponentUpdate() to let React know if a component’s output is not affected by the current change in state or props. The default behavior is to re-render on every state change, and in the vast majority of cases you should rely on the default behavior.
source: https://reactjs.org/docs/react-component.html#shouldcomponentupdate
@zarasyversen Thank you for this contribution. My understanding from reading the doc is that PureComponents is a way to reduce the number of re-renders and improves performance. Instead of always re-rendering what state
or props
change you can write a function shouldComponentUpdate()
to let the component know what changes it can disregard (and thus not trigger unnecessary re-renders)
13 Christmas Counter 🎅 🤶 🎄 🎁
I added a Christmas Counter component in
Components/Christmas
With some free svg icons as well - I wasn't sure about the non-christmas one lol so it became a drum, like drumroll! I need to give credit for the icons so added it in a footer. Let me know how you feel about it! I also move some of the CSS we can use reuse from App.css and moved it to index.css.If it's not Christmas:
If it is Christmas:
I have not linked my component at all as I am unsure how we will add the different holidays - like will they be different routes or just switching between components. Locally I just switched out the app rendered in index.js to use my new component
import Christmas from './Components/Christmas';
I am quite new to React and I was unsure what this does:
Instead, I imported
{ Component }
at the top and didclass Christmas extends Component
instead. Hope that is ok! Seemed to work the same.