Skip to content

Conversation

@chrisvxd
Copy link
Contributor

@chrisvxd chrisvxd commented Sep 14, 2020

Fixes rehydrateChildren to work with containerises approach defined in #3. I've tried to drop any special terminology.

What?

It works the same as before, but as convention suggest using own selectors instead of data-rehydratable-children and referring to method as rehydrate, as it's just a prebaked version of the main rehydrate method.

export default async (el, rehydrate) => {
  const children = await rehydrate(el.querySelector('.my-component-children'));

  return <MyComponent>
    {children}
  </MyComponent>;
};

Breaking changes

  • rehydrateChildren is no longer exported from the lib
  • rehydrateChildren is no longer provided to rehydrators. Use children instead.

Update 15/09 - adjusted to reflect that this is actually mostly retaining existing API, but fixing it to align with #3.

@chrisvxd chrisvxd force-pushed the chrisvxd/automatically-rehydrate-children branch from bedec71 to 5e9fb15 Compare September 14, 2020 17:11
@chrisvxd chrisvxd changed the base branch from master to chrisvxd/remove-markup-containers September 15, 2020 14:21
Base automatically changed from chrisvxd/remove-markup-containers to master September 15, 2020 15:08
@chrisvxd chrisvxd force-pushed the chrisvxd/automatically-rehydrate-children branch from 5e9fb15 to 715f562 Compare September 15, 2020 15:30
Copy link
Member

@monospaced monospaced left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem with this: innerHTML !== children

export default () => (
  <Tabs>
    <Tab label="Food 1">Sausages</Tab>
    <Tab label="Food 2">Bacon</Tab>
  </Tabs>
);
<div class="tabs">
  <div class="tabs-buttons">
    <button>Food 1</button>
    <button>Food 2</button>
  </div>
  <div class="tabs-content">
    <div class="tab">
      Sausages
    </div>
    <div class="tab">
      Bacon
    </div>
  </div>
</div>

@chrisvxd chrisvxd force-pushed the chrisvxd/automatically-rehydrate-children branch from 715f562 to 9b0f36e Compare September 15, 2020 16:29
@chrisvxd chrisvxd requested a review from monospaced September 15, 2020 16:33
@chrisvxd chrisvxd changed the title Automatically rehydrate children Fix rehydrate children Sep 16, 2020
@chrisvxd chrisvxd merged commit 0f13d96 into master Sep 16, 2020
@chrisvxd chrisvxd deleted the chrisvxd/automatically-rehydrate-children branch September 16, 2020 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants