andreypopp/reactify

React 0.12 - Components may not be called directly

Closed this issue · 4 comments

React 0.12 has changed the way they handle components.

Components now produce the error: App is calling a React component directly. Use a factory or JSX instead. See: http://fb.me/react-legacyfactory

The document gives several options, but I don't know the best while using reactify.

What version of reactify do you use? This was fixed started with 0.15.0.

0.15.2

I must be doing something else wrong. Do I need to require the components differently? Or use the factory?

Can you show the code?

Aha. I fixed it. The problem was I had a number of very small React components that I was declaring in the same file (so they were not required) and then I was calling them directly. By adding React.createFactory it stopped giving me the warning.

var Item = React.createFactory( React.createClass({ 
    [...]
}))


var Items = React.createClass({

  render: function() {
    var children = [...]

    var array = children.map( function(item) {
      return Item({key: item})
    })
})

Is this the right way to fix the problem? And then there are a number of other react npm modules that haven't been updated to React 0.12 and are calling the error.