Raphael.FreeTransform icon indicating copy to clipboard operation
Raphael.FreeTransform copied to clipboard

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

Open AnurajRicky opened this issue 6 years ago • 2 comments

AnurajRicky avatar Jun 13 '18 08:06 AnurajRicky

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.

beasteers avatar Nov 04 '18 22:11 beasteers

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

Thanks, do let me know.

kaleem-elahi avatar Feb 12 '20 07:02 kaleem-elahi