welcome-apps icon indicating copy to clipboard operation
welcome-apps copied to clipboard

Quickstart react

Open mminin opened this issue 2 years ago • 1 comments

The tutorial does not explain how the colour button in Customise View supposed to change the background colour. Using colour picker has no effect. Probably because a hook for it is missing in App.js? It seems to be necessary to add the following line under const App:

const [background_color, setSettingsBG] = useState('red');

And then a handler under useEffect()

monday.listen("settings", (res_set) => {
      setSettingsBG(res_set.data.background_color);
    });

and finally assign a style to the div:

const mystyle = {
    backgroundColor: background_color
  };
  console.log(background_color);

  return (
    <div className="App"
        style={mystyle}
          >
      <AttentionBox
        title="Hello Monday Appssss!"
        text={attentionBoxText}
        type="success"
      />
    </div>

mminin avatar Jan 20 '23 19:01 mminin

More than that, you will need to persist the setting for your own App and load them at the start of the App execution, otherwise each invocation of the app will start with undefined settings.

pslootweg avatar Feb 02 '23 19:02 pslootweg