Replies: 10 comments
-
Two things here.
|
Beta Was this translation helpful? Give feedback.
-
On the other hand, depending on what you need, this seems like overkill. You should be able to get away with applying |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
Using the Using the same approach, it is possible to pass and receive context in React. |
Beta Was this translation helpful? Give feedback.
-
Sorry I overlooked that the context is inside the for loop. I believe what you're trying to do is not possible because accessing children instantiates all of them, so there is no opportunity to inject a different context for each child. I don't have the full context of your application code, but I would strongly recommend not going for this pattern even if React supports it. You will be generating a different context each with two accessor functions for each child only to style first and last element differently. Could you perhaps add the |
Beta Was this translation helpful? Give feedback.
-
In |
Beta Was this translation helpful? Give feedback.
-
That should be relatively easy:
|
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
-
This is a good discussion. I'm going to move the issue there. It is behaving as expected. There is no bug here but I'm interested to see how a solution forms out. We do have this sort of chicken and the egg issue since you need to create the elements to iterate over them so there is no way to get context in to them before creating them. |
Beta Was this translation helpful? Give feedback.
-
Please take a look at this example. It should do everything you requested: https://playground.solidjs.com/anonymous/a63a01c0-446c-4424-a307-46cd58803319 |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
I want to add some classes to each child of Compact, but after running the above code, the context printed in the console is undefined, and I cannot figure out where the coding error is.
Your Example Website or App
Nope
Steps to Reproduce the Bug or Issue
I wrote three components.
Expected behavior
Input
should receive the data passed byCompact
through context.Screenshots or Videos
No response
Platform
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions