webpacker-react
webpacker-react copied to clipboard
Mount an Individual View Component
Is it possible to mount an individual component? If not, would it be a reasonable feature request?
My current approach is to unmount all components on the page and then mount them again - but, this resets the state of all components on the page - and I even get inconsistent results when I expect all components to reset.
Consider adding an instance of an Item
component to a page through an ajax request:
document.getElementById('items')
.insertAdjacentHTML('beforeend', '<%= j render partial: 'items/item', locals: { item: @item } %>');
WebpackerReact.unmountComponents()
WebpackerReact.mountComponents()
Here's a change to the webpacker-react-example
that shows the full request/response in action.
https://github.com/renchap/webpacker-react-example/compare/master...sealocal:add-item-with-remote-request
Please share thoughts on mounting a single component on the page.
This should definitely be doable. I will work on implementing this.
@renchap are there any update regarding "mount an individual component"? Do you have any example about this comment https://github.com/renchap/webpacker-react/issues/42#issuecomment-328549657?
BTW: Amazing work, thx!