-
Notifications
You must be signed in to change notification settings - Fork 350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce dynamic props via resolveProps API #187
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
df00ad9
to
0f2bbf4
Compare
e8ed039
to
7753163
Compare
7753163
to
03708bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of questions, approving for expediency
README.md
Outdated
- **type** (`"external"`) | ||
- **adaptor** (`Adaptor`): Content adaptor responsible for fetching data to show in the table | ||
- **name** (`string`): The human-readable name of the adaptor | ||
- **fetchList** (`(adaptorParams: object) => object`): Fetch a list of content and return an array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could Adaptors fetch an object instead of a list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They could fetch an object but this method needs to return an array to populate the table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if "a list of content" is correct in that case? Maybe Fetch content and return an array
? I could be missing the point here 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated to Fetch content from a third-party API and return an array
for clarity
@@ -5,7 +5,7 @@ import { | |||
useCallback, | |||
useState, | |||
} from "react"; | |||
import { Config, Data } from "../../types/Config"; | |||
import { Config, Data, MappedItem } from "../../types/Config"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imported but not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
…ps API The resolveProps API provides all functionality of the _data field and allows for dynamic prop resolution. This is a breaking change.
NPM autocomplete renders the HTML for the badges rather than the markdown.
03708bd
to
d960013
Compare
This PR that introduces new APIs for expanding the capability of adaptors
resolveProp
config API allows users to modify props dynamically without writing them to the Puck data model on a per-component basis.resolveData
util function allows users to apply their dynamic props on the server or client before rendering their page with the<Render>
componentmapProp
adaptor API to enable the user to return change the shape of the data returned by the adaptor before applying it as a propAdditionally:
_data
API for adaptors in favour ofresolveProp
. This is a breaking change.resolveProps Usage
The Hero component in the demo app contains an example
Pairing it with an adaptor
resolveData usage
This should be used by the user to resolve data before rendering their component. It should ideally be used server-side, but can also be used client side in a
useEffect
hook.mapProp usage
Tasks