Skip to content

Conversation

@sfc-gh-dmatthews
Copy link
Contributor

📚 Context

Conceptual guides for custom components v2.

Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

Copy link
Contributor

@sfc-gh-bnisco sfc-gh-bnisco left a comment

Choose a reason for hiding this comment

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

Not yet done with reviewing this PR, but wanted to leave some feedback at this checkpoint. Will come back and go through the remaining docs soon.

Comment on lines +579 to +588
For development, temporarily use the dev server URL:
```python
# Development mode (temporary)
component = st.components.v2.component(
name="my_component",
js="http://localhost:5173/src/index.ts", # Dev server URL
data={"message": "Hello"}
)
```
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: This is incorrect, and feels like a relic of the V1 pattern. With the library build system we have set up in Vite (in the component-template repo), it doesn't run its own server. It still outputs just a file that is hashed, so js="index-*.js", is still the correct value here.

## Publishing your package
### Build the distribution
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Similar feedback here with other sections in this doc, but I don't know how in-depth we should go here considering this isn't Streamlit-specific to publish a package to PyPI. People have their own opinionated ways of building and deploying, so might make our lives simpler to cut this and instead suggest that they can build, package, and deploy to PyPI.

Generally speaking, users who are going to build an entire CCv2 package-based component are already advanced users anyway, so this should be fine.

Comment on lines +696 to +701
interface ComponentProps {
data: MyComponentData;
setStateValue: (key: string, value: any) => void;
setTriggerValue: (key: string, value: any) => void;
parentElement: HTMLElement;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Point folks to using the types from @streamlit/component-v2-lib. This suggests that they redefine the types that we've already provided for them in that package, which is not recommended.

};
} catch (error) {
console.error("Component error:", error);
component.parentElement.innerHTML = `<div class="error">Component failed to load</div>`;
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: I wouldn't recommend this pattern as written, since this goes against our earlier best practice of not overwriting the entire parentElement.

Additionally, this wraps the entire component in a try/catch, which is also not a recommended pattern for any non-trivial component.

Instead of this specific example, I'd instead call out that error handling in the custom component is up to the author to handle.

@sfc-gh-dmatthews
Copy link
Contributor Author

@sfc-gh-bnisco Don't worry about the package-based development page yet. It's definitely not ready for review. 😅

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