I use action-bootstrap ModalTrigger to show a heavy modulo-modal (based on the modal reaction-bootstrap), which means sending it as a props:
<ModalTrigger modal={<MyModal field1={value1} field2={value2} (more fields...)/>}> Click here to open </ModalTrigger>
The parent component that creates the trigger has fields / values passed through the details, and the parent component of this component also passed it as details to the top-level component that actually stores the data. Both are mostly pipes, which are the classic childContext script, except that it does not work. Here is a simplified version of what I tried:
var MyModal = React.createClass({ contextTypes : {foo : React.PropTypes.string}, render : function() { return ( <Modal {...this.props} title="MyTitle"> <div className="modal-body"> The context is {this.context.foo} </div> </Modal> ); } }); var Content = React.createClass({ childContextTypes : {foo: React.PropTypes.string}, getChildContext : function() {return {foo : "bar"}}, render : function() { return ( <ModalTrigger modal={<MyModal/>}> <span>Show modal</span> </ModalTrigger> ) } });
The modal pops up with "Context", without displaying the actual context.
I believe this is because the alert sent to ModalTrigger has already been made / mounted in some way, but I'm not sure why. As far as I understand, the owner of MyModal is the Content component, which means that the context should be in order, but this is not so.
Additional info: I already tried passing {...this.props} and context={this.context} to MyModal without any success. Also, possibly relevant, ModalTrigger uses cloneElement to make sure that the modal onRequestHide prop points to the trigger release function.
So what am I missing here?: /
source share