question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apollo + react-chartjs-2 gives me Uncaught TypeError: Cannot add property _meta, object is not extensible

See original GitHub issue

I’m not sure if this is an apollo issue, or a react issue. I keep getting Uncaught TypeError: Cannot add property _meta, object is not extensible

If I use another way to get the data (aside from apollo), such as a meteor method (http REST call, basically), I can pass the response in to my chart. If I grab the data via apollo, which gets added to the props, I can not pass that object into my chart.

I don’t think it has to do with this:

https://github.com/jerairrest/react-chartjs-2/issues/18

if I pass in an empty object, I don’t get any error. It’s only when I pass in the data via apollo/props

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

4reactions
acomitocommented, Jul 17, 2017

This line creates a copy of the props that can be passed in:

let chartData = JSON.parse(JSON.stringify(data.costData))

Works for now and it updates whenever my apollo query reruns

3reactions
acomitocommented, Jul 12, 2017

Clone the props seems to be the short-term workaround.


class MyChart extends React.Component {
	renderChart = () => {
		const { data } = this.props;
		if (data.loading) { return null }
		let chartData = JSON.parse(JSON.stringify(data.costData))
		return <Doughnut data={chartData} />
	}
	render(){
		return (
			<Card>
				<div className='content'>
					{this.renderChart()}
				</div>
			</Card>
		);
	}
}

further reading:

https://stackoverflow.com/questions/41582357/local-copy-of-react-prop-is-read-only

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apollo + react-chartjs-2 gives me Uncaught TypeError: Cannot ...
I was using the annotation plugin. When I write the annotations property statically it works. But when I fetch the from API it...
Read more >
javascript "cannot add property" "object is not extensible ...
apollo client - javascript "cannot add property" "object is not extensible" when I update cache in graphql query - Stack Overflow. Stack ...
Read more >
Array from Cache Not Extensible? - Help - Apollo GraphQL
I've got a React useRef that I use to store my appointments when ... Uncaught TypeError: Cannot add property 8, object is not...
Read more >
Apollo + react-chartjs-2 gives me Uncaught TypeError: Cannot add ...
I'm not sure if this is an apollo issue, or a react issue. I keep getting. Uncaught TypeError: Cannot add property _meta, object...
Read more >
TypeError: invalid assignment to const "x" - JavaScript | MDN
A constant is a value that cannot be altered by the program during normal execution. It cannot change through re-assignment, and it can't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found