Currently, I am in the process of developing a search page in Vue 3 using the composition API. One of my components is responsible for displaying a snippet of data that includes specific keywords provided by the parent component. To achieve this, I need to create a displayable value based on the original data.
Initially, I made the mistake of assuming that simply fetching the props value like this would suffice:
setup(props) {
const displayEntry = ref(props.entry)
...
However, this approach turned out to be reactive and caused unwanted changes to the original data. Since I don't require reactivity for this particular task as the component is dynamically created from the parent, storing a working copy of the data in the parent would only add unnecessary complexity to the code. After attempting various solutions to break the reactivity cycle, I finally found a simple solution:
displayEntry.value = props.entry
But then, my linter flagged an error:
error Getting a value from the `props` in root scope of `setup()` will cause the value to lose reactivity vue/no-setup-props-destructure
My question now is, what is the correct method to directly access the value from a prop without causing reactivity issues?