-
-
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
TypeError: child._updateFromParent is not a function #62
Comments
Of course, here is a gist I did @apertureless: https://gist.github.com/balibou/2b5c3110fd52d217d4141c323a9b7787 There is a parent component (Dashboard.vue) with 2 child components (TopStats and LineChart). If I try to update data, then I have the error: |
Well I guess, it's a bug in your code, rather then in vue-chartjs.
I am a bit confused, why you have a If you want to use vue files, you can use it like this: LineChart.vue: <script>
import { Line } from 'vue-chartjs'
export default Line.extend({
props: ['options', 'chartData'],
mounted () {
this.renderChart(this.chartData, this.options)
}
})
</script> Are you sure that I also don't see how the chart should update in your example. In your And ... thats it. The reactiveData mixin creates a vue |
Ok thanks for your feedback, I will try to fix it today with your explanation. |
I guess a cleaner way would be to pass your chartData as a prop . And if you're using vuex you can then map the getters and pass it as a prop. import { mapGetters } from 'vuex'
export default {
computed: mapGetters([
'chartdata'
])
} and then pass it as a prop to the line chart. However, I am not sure if you can use the reactiveProp mixin there, because of the limitations on how to mutate arrays and objects. However you could then work with a eventbus and listen on a |
Ok thanks for a lot. |
Still not working ... I took examples (reactive data and reactive props) from this repo. The issue appears when I want to include this logic inside a parent vue component, I have this error of child._updateFromParent ... |
Yeah, but this erros seems to be vue related not |
I'm also having this problem. I'm using vuex, and I noticed that when I remove the following piece of code, the error goes away: beforeMount() {
this.$store.dispatch('getDashboardStats')
this.$store.dispatch('getUsers')
this.$store.dispatch('getLocations')
this.$store.dispatch('getBuildingsByLocation')
} And this is how my vuex actions looks like: getLocations({commit}) {
return new Promise((resolve, reject) => {
Vue.axios.get('location/getbyuser')
.then(response => {
commit('SET_LOCATIONS', response.data)
resolve(response)
})
.catch(error => {
reject(error)
})
})
} Also, for testing purposes, I have the data for the chart hardcoded on data(), like: d: {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [
{
label: 'Score',
backgroundColor: '#f87979',
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}
]
} Maybe some conflicts with vuex? |
Well yet again, without a working example to debug, I can't really help. For me this erros seems more related to vuex / vue lifecycle. Generally vue-chartjs is working with vuex. Sample project: |
Updating my packages to its latest versions seems like fixed the problem. I was using: |
Btw, using your example, I'm getting the following warning: [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. |
Was a version mismatch of vue-chartjs. |
@apertureless I have the same issue as mentioned. When I load my page for the first time with the logged in user, I get the correct data, no errors, but when I select another user I get the error as above. If I remove the chart code the data loads fine. Here is the code gist |
Expected Behavior
When I update chart data, I want the chart to be updated.
Actual Behavior
When I update chart data, I get the error
TypeError: child._updateFromParent is not a function
(I tried to pass data throught event, vuex, and even tried to forceUpdate)
This is an error I got with the reactive prop example too (so I used reactive data example).
Environment
The text was updated successfully, but these errors were encountered: