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

How to destroy CanvasSpace? #16

Open
amorino opened this issue Jul 22, 2016 · 1 comment
Open

How to destroy CanvasSpace? #16

amorino opened this issue Jul 22, 2016 · 1 comment

Comments

@amorino
Copy link

amorino commented Jul 22, 2016

For example, when I use Pt with React I should be able to destroy the Canvas Instance when the component leave.

@williamngan
Copy link
Owner

Good question. My first guess would be to create a <canvas> in React, and then simply reference it in Pt.

React:

render() {
    return(<canvas id="hello"></canvas>)
}

Then to instantiate Pt by referencing the id:

new CanvasSpace("#hello").setup(...);  

Use the latest v0.2 version. This won't work in Pt v0.1 because of a constructor bug.

Probably you'll need to clean up the Pt instance in React's componentWillUnmount() (or something like that), so that it won't try to draw to an element that no longer exists.

Hope this will work. If not, we'll fix it. 💪 Cheers!

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

No branches or pull requests

2 participants