arunoda / react-komposer

Feed data into React components by composing containers.
MIT License
733 stars 70 forks source link

Cannot read property 'header' of undefined . React-komposer and meteor #116

Closed Tevinthuku closed 8 years ago

Tevinthuku commented 8 years ago

This is my container

import { Meteor } from 'meteor/meteor';
import React from 'react';
import { composeWithTracker } from 'react-komposer';
import CircularProgress from 'material-ui/CircularProgress';
import darkBaseTheme from 'material-ui/styles/baseThemes/darkBaseTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import Questiondetails from '../../../ui/components/Questiondetails/Questiondetails.jsx';
import Questions from '../../Collections/Questions/Questions.js';

function composer(props, onData) {
  const handle = Meteor.subscribe('singleQuestion', props._id);

  if (handle.ready()) {
    const thequestion = Questions.findOne({ id: props._id });
    onData(null, { thequestion });
  }
}

const darkMuiTheme = getMuiTheme(darkBaseTheme);

const MyLoading = () => (<div style={{ width: '90%', position: 'relative' }}>
  <MuiThemeProvider muiTheme={darkMuiTheme}>
    <div style={{ margin: 'auto', right: 0, left: 0, maxWidth: 200, position: 'relative' }}>
      <CircularProgress size={1.0} />
    </div>
  </MuiThemeProvider>
</div>);

export { MyLoading };

export default composeWithTracker(composer, MyLoading)(Questiondetails);

and this is my component

import React from 'react';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';

const lightMuiTheme = getMuiTheme(lightBaseTheme);

const Questiondetails = ({ thequestion }) => (
  <div>
    <MuiThemeProvider muiTheme={lightMuiTheme}>
      <h4>{thequestion.header}</h4>
    </MuiThemeProvider>
  </div>
);

export default Questiondetails;

What could be the problem as Im getting Cannot read property 'header' of undefined . at ReactCompositeComponentWrapper._constructComponentWithoutOwner (ReactCompositeComponent.js:321)

meepeek commented 8 years ago

I have the same issue

Tevinthuku commented 8 years ago

I found a solution.

stackoverflow.com/questions/38972184/react-komposer-react-and-meteor

On Wed, Aug 17, 2016, 6:46 PM Thee, Meepeek notifications@github.com wrote:

I have the same issue

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kadirahq/react-komposer/issues/116#issuecomment-240454741, or mute the thread https://github.com/notifications/unsubscribe-auth/ALkPmT_lcZojF4gWDBYmxwq7cU_qOXgQks5qgyzFgaJpZM4JlOJQ .