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

Unclear how to instantiate component in README #14

Closed
damassi opened this issue Mar 17, 2014 · 1 comment
Closed

Unclear how to instantiate component in README #14

damassi opened this issue Mar 17, 2014 · 1 comment

Comments

@damassi
Copy link

damassi commented Mar 17, 2014

When reading over the documentation, instantiation is a bit confusing. The last line says

var user = new Backbone.Model();
var userView = UserView({model: user});

But in the React documentation that's generally not how instantiation / adding to dom occurs:

_HelloMessage.coffee_

HelloMessage = React.createBackboneClass
   changeOptions: 'change:name'

   render: ->
      `<div className='test' onMouseOver={this.onClick}>{'Hello ' + this.props.name}</div>`

   onClick: (event) ->
      console.log 'hey!'

module.exports = HelloMessage

and then in main.coffee

HelloMessage = require './views/landing/LandingView.coffee'

React.renderComponent(
   `<HelloMessage />,
   document.getElementById('wrapper')`
)

How exactly do you pass your model into the component? Returning a HelloMessage({ model: model }}) doesn't work as it should, but a simple addition of

React.renderComponent( HelloMessage({ model: user}), document.getElementById('wrapper'))

... would suffice for users new to the library and wrapper.

Do you think you can provide a more full-featured usage example on the README? It would be much appreciated.

Thanks!

@clayallsopp
Copy link
Owner

Thanks for the heads-up - to clarify, a React.createBackboneClass class looks for props.model, which you can inject however is best for your application.

I've added an extended example to the docs: e65cd27

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

No branches or pull requests

2 participants