Skip to content

Mount an Individual View Component #37

@sealocal

Description

@sealocal

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.
renchap/webpacker-react-example@master...sealocal:add-item-with-remote-request

Please share thoughts on mounting a single component on the page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions