I am using this helper to display a datepicker component
      <%= react_component "MyDatePicker", startDate: '', endDate: ''%>
I want to pass javascript values to startDate and endDate props. Any possible way to do this?
I am using this helper to display a datepicker component
      <%= react_component "MyDatePicker", startDate: '', endDate: ''%>
I want to pass javascript values to startDate and endDate props. Any possible way to do this?
Fixed this by using
Pubsub. What I did ispublishthe user selected values in the javascript first. Then on react parent component lifecycle method subscribed to the previouslypublishedevent and usesetStateto change thestatebased on that.Now am on mobile but i will publish the code for clarity once i got access to a pc.
update
Using
pubsubis easy. First we need topublishthe required from anywhere using javascriptHere I just pass a dates object. You can pass anything. Then in react's
componentDidMountstate I subscribe to thisHere the first is object we are expecting and the callback
so here is the call back function here you can do anything like ajax call, set state, or anything
And finally unsubscribe when component
unmountsThis is how I implemented it. I no longer have the code but I hope you got the point.