react-sketch icon indicating copy to clipboard operation
react-sketch copied to clipboard

Changing tool dynamically randomly ends up with undefined tool sometimes

Open garretthogan opened this issue 8 years ago • 3 comments

handleClickTool(event) {
    const value = event.target.innerText;
    this.setState({
      selectedTool: value
    });
  }
render() {
  console.log(this.state.selectedTool);
  const width = window.innerWidth;
  const height = window.innerHeight;
  return (
    <div>
      <ToolPanel handleClickTool={this.handleClickTool} selectedTool={this.state.selectedTool} />
      <SketchField
        ref={(c) => this._sketch = c} 
        style={{position: 'absolute'}}
        width={width} 
        height={height} 
        tool={this.state.selectedTool}
        color='black'
        lineWidth={3}
      />
    </div>
  );
}

Selected tool always has a valid string value but the tool will randomly end up being a pencil even when the valid tool is supplied.

garretthogan avatar Sep 18 '17 03:09 garretthogan

Can you recreate the bug and post the link to it.

inf3cti0n95 avatar Nov 22 '17 11:11 inf3cti0n95

Is this still valid?

tbolis avatar Nov 23 '17 07:11 tbolis

@garretthogan I believe the value you are passing to the tool prop in not one of the predefined tools which the SketchField Supports and that is why it is using Pencil tool as a fallback. The Value for tool should be one of the listed below

  • Circle: 'circle'
  • Line: 'line'
  • Pencil: 'pencil'
  • Rectangle: 'rectangle'
  • Select: 'select'
  • Pan: 'pan'

inf3cti0n95 avatar Nov 27 '17 07:11 inf3cti0n95