-
-
Notifications
You must be signed in to change notification settings - Fork 836
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
Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders #151
Comments
If I replace this line: <line-chart :chart-data="datacollection"></line-chart> On this line: <line-chart :chart-data="datacollection" :options="{ responsive: true, maintainAspectRatio: false }"></line-chart> Then in the logs of the browser I get a second error:
|
Can you please provide a codepen for reproduction? |
@apertureless I updated all the packages to the current versions. Now there is another error. I updated my first post.
I'm using the latest versions. I only use your code. You can perfectly reproduce the problem in yourself. Please. P.S. I do not know how to demonstrate the .vue component on the codepen. Once again, I'll write that my code is identical to your code from the documentation. |
@afuno This is how you can create a component without creating a new
|
@denislapi I do not need to create components this way. I use .vue components in the project. The question concerns only .vue files. The author wrote the code in their documentation, which is not working properly. |
@afuno I just wanted to show you how to create a component on Codepen, that was actually answer on your question/confusion how to create it.
Peace! |
https://github.com/vuejs/vue/releases/tag/v2.4.0 ($attrs is a new feature of vue). |
@someother1 This doesn't correct the main problem. |
How about adding the options directly on your chartRender function, instead of using the :options. |
Well thats weird. I have the reactive prop example here in this repo And running here And the mutating warning for the options is also weird. As the options never get mutated at any point. Can you check out this repo and see if I will check for the However... it is also very weird... because as |
Okay, I updated the peerDependency to match the current vue version. Any other have this warning? |
@apertureless I will write for the time being only about :( |
Hm, thats interesting. Well that are only warnings. What is your build setup? Webpack 2? |
@apertureless Hi, I had the same Issues chart.js
chart.vue
It's similar to Example http://vue-chartjs.org/#/home?id=reactive-data It works, but has some warning.
and
My package.json
|
New findings. The actual version is Vue 2.4
If I add some props(width or height) and do some operations(example: change v-model data), there will be warnings.
After removing the props, the warning disappears.
|
Can you create a minimal repository for reproduction? Right now with a clean vue cli scaffold, I can not reproduce it. |
@apertureless You are right |
I had exactly the same problem, but its gone after I upgraded vue from 2.2.2 to 2.4.2 |
+1 same issue here with the latest version of Vue |
Hey @farefray , @hambos22 did you scaffolded the project with vue-cli ? Which template? Could someone of you provide a minimal repository for reproduction? |
@apertureless I think i'm running into this too. Made a small repo to reproduce: It might be me doing something wrong too 🐱 |
Thanks @jenslind ! Will look into this. |
Hello @apertureless. First of all I forgot to thank you for this very useful project! Great work! I didn't scaffold with vue-cli. I'm having this issue with vanilla laravel installation. |
@hambos22 okay thanks for the info. I will check it out. |
Yes exactly |
I seem to be having this issue as well using vue-chartjs@2.8.2 / vue@2.4.2 in my electron app. I'm literally using the same chart code and same vue/vue-chartjs versions on the non electron version and i get no errors. Not sure what to make of that! |
I will check the electron boilerplate if I find some time. |
Are you using webpack 1 or 2? Sent from my OnePlus ONEPLUS A3003 using FastHub |
I am currently using Webpack 2. The app I'm having issues with was deployed via https://github.com/SimulatedGREG/electron-vue |
|
I'm currently getting this warning as well. I'm also using the electron-vue project at https://github.com/SimulatedGREG/electron-vue. I've made a wrapper component similar to that used by Vuestic-Admin at https://github.com/epicmaxco/vuestic-admin
The warnings show up whenever the data changes. Everything appears to work correctly, it's just console warnings at the moment. I will continue trying to solve this. |
Well this seems to be related to electron. However I am not sure why... and it only appears if you're using the bundled version. |
Okay, I am still not sure, why. But it seems that electron does not like the However you could also use the extend in the component or as a mixin. <script>
import {Line, mixins} from 'vue-chartjs'
const {reactiveProp} = mixins
export default {
mixins: [reactiveProp, Line],
mounted () {
this.renderChart(this.chartData, {responsive: true, maintainAspectRatio: false})
}
}
</script> or <script>
import {Line, mixins} from 'vue-chartjs'
const {reactiveProp} = mixins
export default {
extends: Line,
mixins: [reactiveProp],
mounted () {
this.renderChart(this.chartData, {responsive: true, maintainAspectRatio: false})
}
}
</script> This way no warnings get thrown. |
Thanks. That does prevent the warnings. Strange issue. |
Expected Behavior
The values in the chart should be changed without any errors.
I mean this code: http://vue-chartjs.org/#/home?id=reactive-data
Actual Behavior
The chart is initialized. The values are displayed. After pressing the button, the values change.
But in the logs of the browser, this errors always appears:
And second:
My code is exactly the same as your code in the documentation. I did not specifically change it.
Environment
The text was updated successfully, but these errors were encountered: