Open MarkLyck opened 7 years ago
This issue is occurring for me as well. I am also using Next.js
Make sure you're importing things correctly. I had the same issue when i tried to import a component like this:
import { ProfileImage } from '../components/ProfileImage';
instead of like this:
import ProfileImage from '../components/ProfileImage';
I have been unable to reproduce this issue.
I have tested all of our examples with React 16 and they all work perfectly.
Can you please show me the code that you are using to import amcharts3-react
?
Also, make sure that you are using version 3.0.2
of amcharts3-react
This was happening to me with next.js and a shared lerna library on some shared code and the problem was the react component wasn't defined with a const, instead it looked like this:
let Thing = () => {
return (
<span>Test</span>
)
}
export Thing
However the 'Thing' component needed to be a const. I'm assuming the variable was disappearing from scope and thus the error. Not sure if it is the same issue you might be having, but I hope to help some one.
//This worked
export const Thing = () => {
return (
<span>Test</span>
)
}
@rickbyington Your first code example is invalid. Try this code instead:
let Thing = () => {
return (
<span>Test</span>
)
}
export { Thing }
(Notice the {}
around Thing
)
@Pauan I'm getting the exact same crash on server side rendering. I narrowed it down and it seems the crash is this:
TypeError: Cannot read property 'toLowerCase' of undefined at a.renderDOM (/Users/hirad/projects/react_app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:405) at a.render (/Users/hirad/projects/react_app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:228) at a.read (/Users/hirad/projects/react_app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:35:250) at renderToString (/Users/hirad/projects/react_app/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:6) at /Users/hirad/projects/react_app/config/server/handleRender.js:72:44
Apparently the type is undefiend. This is the object that is trying to run toLowerCase() on:
{ '$$typeof': Symbol(react.element), type: undefined, key: '.1', ref: null, props: { options: { type: 'serial', theme: 'light', color: 'white', chartCursor: [Object], categoryField: 'date', categoryAxis: [Object], valueAxes: [Object], autoMargins: false, marginRight: 50, marginLeft: 125, marginBottom: 80, marginTop: 10, legend: [Object], graphs: [Object], dataProvider: [Object] }, style: { width: '100%', height: '450px' } }, _owner: null }
I following the example to load my chart:
<AmCharts.React options={chartsConfig} style={{ width: '100%', height: graphHeight, ...printStyles, }} />
did you also update react-dom ?
what was the solution?
update react-dom solves the issue
I'm rewriting an application in React Fiber and AmCharts no longer seems to work.
I can console log AmCharts and AmCharts.React just fine, but as soon as I try to render it like so:
return <AmCharts.React {...config} />
I get the following error:
AmCharts version 2.0.7
any idea how to fix this?