Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Prevent using variable from outer scope #10766

Closed
wants to merge 1 commit into from
Closed

[docs] Prevent using variable from outer scope #10766

wants to merge 1 commit into from

Conversation

wa-Nadoo
Copy link

Small fix that prevents leaking a variable to the outer scope. If you modify initial code sample in the following manner you will get Uncaught ReferenceError:

function Example(props) {
  function handleChange(e) {
    model.set('firstName', e.target.value);
  }

  return (
    <BackboneNameInput
      model={props.model}
      handleChange={handleChange}
    />
  );
}

ReactDOM.render(
  <Example model={new Backbone.Model({ firstName: 'Frodo' })} />,
  document.getElementById('root')
);

Demo of the bug: https://codepen.io/wa-Nadoo/pen/EwyyqE?editors=0010
Fixed code sample: https://codepen.io/wa-Nadoo/pen/PJzGPq?editors=0010

@gaearon
Copy link
Collaborator

gaearon commented Nov 21, 2017

Thanks! We moved the docs into a different repo but I made a fix in reactjs/react.dev@7d8abd8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants