Browse Source

Minor tweaks

main
Dan Abramov 7 years ago
committed by GitHub
parent
commit
d73bb5d287
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      content/docs/faq-functions.md

11
content/docs/faq-functions.md

@ -24,7 +24,8 @@ There are several ways to make sure functions have access to component attribute
```jsx ```jsx
class Foo extends Component { class Foo extends Component {
constructor () { constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this); this.handleClick = this.handleClick.bind(this);
} }
handleClick() { handleClick() {
@ -54,7 +55,7 @@ class Foo extends Component {
```jsx ```jsx
class Foo extends Component { class Foo extends Component {
handleClick () { handleClick() {
console.log('Click happened'); console.log('Click happened');
} }
render() { render() {
@ -65,13 +66,13 @@ class Foo extends Component {
>**Note:** >**Note:**
> >
>Using `Function.prototype.bind` in render creates a new function each time the component renders, which may have performance implications; (see below). >Using `Function.prototype.bind` in render creates a new function each time the component renders, which may have performance implications (see below).
#### Arrow Function in Render #### Arrow Function in Render
```jsx ```jsx
class Foo extends Component { class Foo extends Component {
handleClick () { handleClick() {
console.log('Click happened'); console.log('Click happened');
} }
render() { render() {
@ -82,7 +83,7 @@ class Foo extends Component {
>**Note:** >**Note:**
> >
>Using an arrow function in render creates a new function each time the component renders, which may have performance implications; (see below). >Using an arrow function in render creates a new function each time the component renders, which may have performance implications (see below).
### Is it OK to use arrow functions in render methods? ### Is it OK to use arrow functions in render methods?

Loading…
Cancel
Save