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

Is there any version of this code as a functional component? #177

Open
kanishkkp opened this issue Nov 29, 2022 · 1 comment
Open

Is there any version of this code as a functional component? #177

kanishkkp opened this issue Nov 29, 2022 · 1 comment

Comments

@kanishkkp
Copy link

No description provided.

@sojinsamuel
Copy link

Will this do:

import { useState } from 'react';
import { SketchField, Tools } from 'react-sketch';

const ReactSketch = () => {
  const [tool, setTool] = useState(Tools.Pencil); 
  const [lineColor, setLineColor] = useState('black'); 

  return (
    <div>
      <SketchField
        width="800px" 
        height="400px"
        tool={tool} 
        lineColor={lineColor}
      />
      <button onClick={() => setTool(Tools.Pencil)}>Pencil</button>
      <button onClick={() => setTool(Tools.Rectangle)}>Rectangle</button>
      {/* Add more buttons for different tools if needed */}
    </div>
  );
};

export default DrawingComponent;

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