Support custom rehydratable query selectors #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Blocked by #4. Migrated from simon360/react-from-markup#49.
What?
Enables custom query selectors, which can eliminate any custom markup.
Instead of this
You can now have this
By configuring your rehydrate method with the new
getQuerySelector()
methodHow?
This PR extends replaces reading of the
data-rehydratable
attribute with a query selector. By default, this query selector will check fordata-rehydratable
, but this can be overridden using thegetQuerySelector
param.You can get quite creative with your selectors, targeting whatever you want.
Breaking changes
This PR contains no breaking changes
Considerations
There is a slight performance penalty to doing this instead of reading the
data-rehydratable
attribute directly, in particular due to the introduction of some new loops. I'll do my best to point them out via PR line comments.TODO
Docs