Skip to content
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

JSX issue with ref and van-debug #423

Closed
thednp opened this issue Mar 13, 2025 · 3 comments
Closed

JSX issue with ref and van-debug #423

thednp opened this issue Mar 13, 2025 · 3 comments

Comments

@thednp
Copy link
Contributor

thednp commented Mar 13, 2025

I'm working on the vite-plugin-vanjs and I implemented a new feature: in development, load van.debug.js else load van.js. The problem is that our JSX implementation is using JSX ref as a van.state, (just like the original van-jsx implementation we forked) however van.debug throws

Error: DOM Node is not valid value for state

@Tao-VanJS how should we proceed? What's the point of checking that?

@Tao-VanJS
Copy link
Member

We discourage having DOM-node-valued states. This is why you're seeing the error in van.debug.js. See https://vanjs.org/advanced#why-not-dom-valued-states for more information.

@thednp
Copy link
Contributor Author

thednp commented Mar 13, 2025

The issue happens in this code, something is not right with const anchor = van.tags.a(newProps, ...children); Error: van.js:18 Error: Invalid property value for children: Only string, number, boolean, bigint and null are valid prop value types can you please advise?

Do I need to do the check protoOf like vanjs?

@thednp
Copy link
Contributor Author

thednp commented Mar 14, 2025

@Tao-VanJS I found the problem: it's all about props, they need to be defined, so something like:
Object.fromEntries(Object.entries(props).filter(([_, val]) => val)

filter fixes that.

@thednp thednp closed this as completed Mar 14, 2025
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

No branches or pull requests

2 participants