holen icon indicating copy to clipboard operation
holen copied to clipboard

Suggestion: pass url to render prop

Open jamesplease opened this issue 7 years ago • 2 comments

One thing users may need to do is modify the URL based on the state of whatever is rendered from within the render prop. An example would be setting the "base URL" on <Holen/> and then configuring query parameters within the components rendered in render/children.

Example:

// parent.js
<Holen url="/posts" lazy>
  (result) => (<Child {...result}/>)
</Holen>

// child.js
this.props.fetch({
  url: this.props.url + qs.stringify(this.state.query)
});

This usage of the API can be thought of as Holen preparing some default configuration of the fetch for the child to then further customize.

jamesplease avatar Jan 21 '18 22:01 jamesplease

This is a great idea. Are there any other values that would be useful to pass?

tkh44 avatar Jan 22 '18 17:01 tkh44

I can't think of any others right now, but I'll let ya know if that changes :v:

I'll PR this shortly.

jamesplease avatar Jan 22 '18 17:01 jamesplease