Skip to content

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