Skip to content

Instantly share code, notes, and snippets.

View 3stacks's full-sized avatar
🐻
here comes the beast

Luke Boyle 3stacks

🐻
here comes the beast
View GitHub Profile
@3stacks
3stacks / doctors.js
Last active March 5, 2018 10:30 — forked from duyenho/doctors.js
performance - how to avoid bindings in react's render function
// I removed everything bar the component with the binds and hopefully I can just point you in the right direction.
// when we look at doctorFormBlocks.map, there's two issues. One being that you're creating a new function instance with your
// bind every render (which you correctly identified). But two, your map has an arrow function inside it which also results
// a new function instance every render! This would certainly add up.
// Below is the class as you had it before. The way I would do it is to just make your map an instance method on
// the component.
// Before
export default class DoctorsPage extends React.Component {
// For each image in the dataset, output this object:
// { src: "picture-3.jpg", caption: "Lorem Ipsum Dolor 2<br>Ut enim ad minim veniam, quis nostrud exercitation ullamco<br>2017" }
const data = [
{
"title": "Lorem Ipsum Dolor 1",
"description": "Ut enim ad minim veniam, quis nostrud exercitation ullamco.",
"year": "2018",
"images": [
"picture-1.jpg",