Title: Feature Request: Set default value for apiEndpoint in SmartImage
Description
Currently, when using the SmartImage component, developers are required to explicitly pass the apiEndpoint prop. Since the recommended workflow relies on "http://localhost:8000/api/generate-caption", requiring this prop creates unnecessary boilerplate for the standard use case.
I propose making apiEndpoint an optional prop with "http://localhost:8000/api/generate-caption" as its default value.
Current Behavior
Right now, developers have to write this every time they use the component:
import { SmartImage } from 'react-a11y-auto-caption';
export default function Demo() {
return (
<SmartImage
src="https://example.com/image.jpg"
apiEndpoint="http://localhost:8000/api/generate-caption"
);
}
Proposed Behavior
If we set the default prop inside the component, developers can omit it entirely for the standard workflow, while still retaining the ability to override it if they are using a custom endpoint:
import { SmartImage } from 'react-a11y-auto-caption';
export default function Demo() {
return (
<SmartImage
src="https://example.com/image.jpg"
// apiEndpoint defaults to "http://localhost:8000/api/generate-caption"
/>
);
}
Benefits
- Better DX (Developer Experience): Reduces repetitive code and boilerplate.
- Easier Onboarding: New users can get started immediately with the recommended workflow without needing to copy-paste the local endpoint URL.
- Backwards Compatible: Existing code explicitly passing the prop will continue to work normally.
Let me know if you'd like me to open a PR for this!
Title: Feature Request: Set default value for
apiEndpointinSmartImageDescription
Currently, when using the
SmartImagecomponent, developers are required to explicitly pass theapiEndpointprop. Since the recommended workflow relies on"http://localhost:8000/api/generate-caption", requiring this prop creates unnecessary boilerplate for the standard use case.I propose making
apiEndpointan optional prop with"http://localhost:8000/api/generate-caption"as its default value.Current Behavior
Right now, developers have to write this every time they use the component:
Proposed Behavior
If we set the default prop inside the component, developers can omit it entirely for the standard workflow, while still retaining the ability to override it if they are using a custom endpoint:
Benefits
Let me know if you'd like me to open a PR for this!