Skip to content

Instantly share code, notes, and snippets.

View vzaidman's full-sized avatar

Vitali Zaidman vzaidman

View GitHub Profile
@vzaidman
vzaidman / index.js
Last active January 25, 2020 13:46
Why Did You Render 4 Released!
import React from 'react';
if (process.env.NODE_ENV !== 'production') {
const whyDidYouRender = require('@welldone-software/why-did-you-render');
whyDidYouRender(React, {
trackAllPureComponents: true,
trackExtraHooks: [[ReactRedux, "useSelector"]]
});
}
@vzaidman
vzaidman / BrokenBigPureComponent.js
Last active January 25, 2020 13:35
Why Did You Render 4 Released!
const BrokenBigPureComponent = React.memo(() => {
const data = useSelector(state => ({ text: state.text }));
return (
<p>{data.text}</p>
);
});
@vzaidman
vzaidman / App.js
Last active November 9, 2019 09:13
App.jsx in it's traspiled form
function App() {
console.log("App - start render");
React.useEffect(() => console.log("App - rendered"));
return React.createElement(
Parent,
null,
React.createElement(Child, null),
React.createElement(Child, null),
React.createElement(Child, null)
@vzaidman
vzaidman / 0-App.jsx
Last active November 9, 2019 09:12
React Rendered By
function App() {
console.log("App - start render");
React.useEffect(() => console.log("App - rendered"));
return (
<Parent>
<Child />
<Child />
<Child />
</Parent>
);
html.colors {
--red: #d47c7c;
--purple: #9e42f5;
}
html.concepts {
--main-brand-color: var(--red);
--secondary-brand-color: var(--purple);
--main-shadow-color: var(--red);
}
html.colors {
...
--red: #d47c7c;
--purple: #9e42f5;
}
html.entities {
/* ... 50 more enteties */
--action-button-background-color: var(--red);
--action-button-shadow-color: var(--red);
<section id="about-us" class="dark-mode-colors dark-mode-entities">
...
</section>
html.dark-mode-colors {
...
--gray: #666;
}
html.dark-mode-entities {
...
--action-button-background-color: var(--gray)
}
html.colors {
...
--red: #d47c7c;
}
html.enteties {
...
--action-button-background-color: var(--red);
}
html.colors {
...
--red: #d47c7c;
}