nylas / component-store-example

An example of the topics covered in Building for Plugins with React & Flux
180 stars 37 forks source link

Passing in containerRequired = false #4

Closed jdarling closed 8 years ago

jdarling commented 9 years ago

How exactly do you pass in the containerRequired as false? I've tried several different approaches but can't seem to figure it out. Any pointers would be great.

grinich commented 9 years ago

@bengotow :smile:

bengotow commented 9 years ago

Hey @jdarling — it looks like the sample code was actually broken, and passing containerRequired: false caused the component not to render. I've pushed a fix for that problem. Here's how you can add the containerRequired: false flag to your components:

// Old-style constructor syntax
MarkAsReadComponent = React.createClass
  displayName: 'MarkAsReadComponent'
  statics:
    containerRequired: false

// Coffeescript class syntax
class MarkAsReadComponent extends React.Component
  @displayName: 'MarkAsReadComponent'
  @containerRequired: false

Hope that helps!

jdarling commented 9 years ago

That makes sense. I found the change ("component" to component) in the generated JavaScript (I don't use CoffeeScript) and a few other opportunities for improvement that once I'm done with my current project I'll try to backport and PR for. Have to say this is a really nice starting point.

Few notes on trip-up's I've ran into:

Still, great work and so glad I ran across your blog post on the subject. Got me started toward a modular frontend to fit my logging, monitoring, analytics dashboard thing :D