Skip to content
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

import failed from react component #217

Open
omertalmi5 opened this issue Nov 16, 2022 · 4 comments · Fixed by #222
Open

import failed from react component #217

omertalmi5 opened this issue Nov 16, 2022 · 4 comments · Fixed by #222

Comments

@omertalmi5
Copy link

I added function-plot as in docs to react component in next.js project as below
`import functionPlot from 'function-plot'
function Form() {
const [realRoot, setRealRoot] = useState(0);
const [imRoot, setImRoot] = useState(0);
const [showResult, setShowResult] = useState(false);

functionPlot({
target: '#plot',
data: [{
fn: 'x^2'
}]
})`

I got the following error,
image

What is the cause, I would be glad to add PR for solving it if needed, thanks

@mauriciopoppe
Copy link
Owner

I added some examples that work with React in https://mauriciopoppe.github.io/function-plot/, I didn't test this with next.js though

@omertalmi5
Copy link
Author

omertalmi5 commented Nov 22, 2022

@mauriciopoppe
It looks like Node.js can't handle with the require('./polyfills') in file index.ts file,
How can I test my assumption?

@mauriciopoppe
Copy link
Owner

Thanks for the pointer, I pushed a fix in #222, you could try pulling the latest commit from master to test it

@Stephen-Mellor
Copy link

Was it determined whether this fixed the issue? I came across the same error when using NextJS, as in the error message above it references the import of d3_shape rather than the polyfills import but I'm struggling to be able to confirm whether the most recent change made a difference. I tried getting the latest version by forking and then installing directly from github but npm threw a billion errors so quite possibly was down to me doing something wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants