Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

How to use this in reactJs project in componentDidMount(){} methode? #157

Open
AnurajRicky opened this issue Jun 13, 2018 · 2 comments
Open

Comments

@AnurajRicky
Copy link

No description provided.

@beasteers
Copy link

beasteers commented Nov 4, 2018

Something like this should work:

import React from "react";
import { Paper, Set, Rect } from 'react-raphael';
import 'Raphael.FreeTransform';

class Rectangle extends React.Component {
    onLoad = (element) => {
        this.transformer = element.paper.freeTransform(element);
    }
    componentWillUnmount() {
        this.transformer.unplug();
    }
    render() {
        return <Rect load={this.onLoad} />;
    }
}
...

You need to use the react-raphael load callback to access the element because it may not be loaded at the time of componentDidMount.

@kaleem-elahi
Copy link

@AnurajRicky @beasteers Did this worked ?
like importing like that "import 'Raphael.FreeTransform';".

Thanks, do let me know.

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

No branches or pull requests

3 participants