0

Similar to the following question: With getComponent how to pass props?

I am trying to pass props to getComponents():

getComponents: (nextState, cb) => {
  cb(null, props => {
    return {
      left: <LeftContainer {...props} items={items} />
      center: <CenterContainer {...props} items={centerItems} />
    };
  });
}

For some reason, in my parent route I don't get this.props.left and this.props.center, instead I see this.props.children. And if I try to render it, getComponents() is called but then it expects an array of components and not an object. Am I doing something wrong here?

Pankaj Vishwani
  • 332
  • 1
  • 4
  • 9

1 Answers1

0

Never mind I figured it out. Here's updated getComponents

const getComponents = (nextState, cb) => {
    const leftComp = (props) => <LeftContainer {...props} item={"Left Item"}></LeftContainer>;
    const centerComp = (props) => <CenterContainer {...props} item={"Center Item"}></CenterContainer>;
    cb(null, {left: leftComp, center: centerComp});
};
Pankaj Vishwani
  • 332
  • 1
  • 4
  • 9