bytemd | Hackable Markdown Editor and Viewer | Editor library
kandi X-RAY | bytemd Summary
kandi X-RAY | bytemd Summary
Hackable Markdown Editor and Viewer
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of bytemd
bytemd Key Features
bytemd Examples and Code Snippets
Community Discussions
Trending Discussions on bytemd
QUESTION
I have three files inside a slug. I use slug parameters as directory name.
The problem I am having is everything except the each loop in taglist. For some reason it does not receive the prop tagList
. Any help would be appreciated.
index.svelte
ANSWER
Answered 2021-Jan-15 at 10:41In Svelte, updates are only triggered with an assignment.
In your case that means that when the component is rendered it will render an empty taglist (tagList = []
).
Now in onMount
you do taglist.push
, but as said earlier, this doesn't trigger an update (remember that this function is called after the component has mounted) because it is not an assignment.
There are four ways to fix it in your case:
- after the for loop you do
tagList = tagList
, this is an assignment and will trigger the update. - instead of doing the for loop use a mapping
tagList = response.tags.map(tag => tag)
- instead of doing the for loop you spread the tags into the taglist
tagList = [...response.tags]
- considering you don't do anything with the tags anyway, and tagList is empty and you don't seem to have any other way to update, just assign the tags to it directly
tagList = response.tags
Of course your code might be simplified, if you actually do something with each tag before adding it to the list case 3 and 4 are not good options, for that scenario I would use the map
option
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install bytemd
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page