react icon indicating copy to clipboard operation
react copied to clipboard

Rendering Form builder duplicates component palette on setState

Open perman26 opened this issue 6 years ago • 8 comments

duplicates component palette after changing state because of re render.

perman26 avatar Dec 17 '18 12:12 perman26

Can you provide a form or some steps to reproduce this?

randallknutson avatar Dec 17 '18 15:12 randallknutson

import React, { Component } from 'react';
import {FormBuilder} from 'react-formio';

class App extends Component {

onChangeFormBuilder(schema){
 this.setState({ schema: schema });
}

  render() {
    return (
      <div className="App">
        <FormBuilder 
			form={{ display: 'form' }} 
			onChange={(schema) => this.onChangeFormBuilder(schema)} />
      </div>
    );
  }
}
export default App;

When we change state after onchange, it duplicates component palette

perman26 avatar Dec 18 '18 12:12 perman26

@perman26 Did u get the solution? I need it too

sireeshav avatar Jan 11 '19 07:01 sireeshav

No Solution yet.... I feel this is happening in react version of formio only, in angular and vanilla javascript builder working fine

perman26 avatar Jan 11 '19 08:01 perman26

Even am also facing the same problem. Even i need it too.

vishaldenzil avatar Jan 11 '19 09:01 vishaldenzil

@perman26 @vishaldenzil For now im doing this /* to hide duplicate component pallettes */ .formcomponents{ display: none; } .formcomponents:first-child{ display: initial; }

sireeshav avatar Jan 11 '19 10:01 sireeshav

@sireeshav thank you, Am passing the data to form builder "form" props . If i pass through through api its not taking that data.

 <FormBuilder 
    form={this.state.form} 
    onChange={this.handleData}
    />

If i set to form state through constructor its displaying the form . If i set through setState its giving the problem. I can say its not rendering again .

vishaldenzil avatar Jan 11 '19 10:01 vishaldenzil

Same issue with me. If state is set onChange then multiple pallets appear.

https://github.com/formio/react-formio/issues/228

This might help you as well.

ghost avatar Apr 29 '20 04:04 ghost

I am closing the issue as it was created too long ago and there are no new comments here. I hope it was resolved. If not, please reopen it. Thanks!

TanyaGashtold avatar Aug 31 '23 13:08 TanyaGashtold