-
Notifications
You must be signed in to change notification settings - Fork 82
Not working with nested components #96
Comments
@thebarty, I have the exact case and I'm curious if you've come up with a solution or not |
@SilencerWeb its been a while. had a look at the project I needed this for. I endet up NOT using this package. react-stickynode seems to have worked better… give it a try. Enjoy! |
@thebarty, thanks for the answer! I ended up using custom vanilla JS function :) |
Not sure if the scenario I encountered is same as yours. In the end, I simply had to specify the rootEl prop. |
For anyone else wondering. What I decided to do is flatten the array, and create an object specifying the level and content. Something like this: const h2H3Array = props.strapiArticles["articleSections"]
.map(section => {
return [
{ level: "h2", content: section["title"] },
headingParser(section["content"])
? headingParser(section["content"])
: headingParser(section["content"]),
].flat()
})
.flat()
.filter(item => typeof item !== "undefined")
|
@CharlieGreenman thanks for providing your solution. However, I cannot get it working with map function and send to nested component. See #209 . Could you help me and take a look? Many thanks |
Unfortunately your question is too open ended. If more specific, I could help |
Thanks for getting back to @CharlieGreenman. As you can read in this issue I posted: #209 , I have Home component (home page) with two nested components:
The ScrollSpy component does not work when I perform a map function in the Home component to generate the URLs for the NavBar component. Home component
If I manually type all the articles (without map function) in the NavBar component it works but when using the map function the ScrollSpy component doesn't work anymore. Any advice or tips are welcome! If you require more code or details let me know! Many thanks |
I also went for a similar approach as @CharlieGreenman, I flattened my array and everything works like a charm. My jsx doesn't have the same nested structure, so I encoded the hierarchy of my tree/data by applying classnames based on my desired hierarchy of the actual data. Luckily I didn't need complex styling or that nested structure, so it was much more straightforward for me. |
Hi guys,
can NOT get it working, when using nested component like
The text was updated successfully, but these errors were encountered: