We talk about JavaScript. Each month in Warsaw, Poland.
Bluesoft, Warsaw
Tech freak, sci-fi lover, astro maniac.
"Kiedy życie zaskoczy,
pytam co ma dla mnie jeszcze"
class MyComponent extends React.Component {
...
render() {
console.log(`Rendering ${this.constructor.name}`);
return (
< div>...< /div>
);
}
...
}
< div>
{invitations.map(invitation => (
< div
key={invitation.id}
< div>{invitation.number}< /div>
...
/>
))}
< /div>
< div>
{invitations.map(invitation => (
< Invitation
key={invitation.id}
{...getInvitationProps(invitation)}
/>
))}
< /div>
class MyComponent extends React.Component {
...
shouldComponentUpdate(nextPros, nextState) {
const hasPropsChanged = shallowEqual(nextProps, this.props);
const hasStateChanged = shallowEqual(nextState, this.state);
return !hasPropsChanged && !hasStateChanged;
}
...
}
import update from 'immutability-helper';
const newData = update(myData, {
x: { y: {z: { $set: 7 } } },
a: { b: { $push: [9] } }
});
import moize from 'moize';
const method = (a, b) => {
return a + b;
};
const memoized = moize(method);
memoized(2, 4); // 6
memoized(2, 4); // 6, pulled from cache
import moize from 'moize';
const Foo = ({bar, baz}) => {
return (
< div>
{bar} {baz}
< /div>
);
};
export default moize.react(Foo);