[Suggestion / feature request] DamlHubLogin from @daml/hub-react, onClick

I want to pass onClick callback to my rendered button via the render option, however at the moment I don’t think it’s possible, unless I’m doing something wrong here. The end goal is to toggle a loading state when I click login.

I’m guessing it’s due to this line

What I’d like to be able to do is pass in a function that can set a state, eg isLoading, so when I click on the button, I can get some reaction

My component looks like this, and I want to pass an onClick to the LoadingButton componenet.

<DamlHubLoginBtn
        withButton
        withToken
        onLogin={(creds) => {
          console.log("ON LOGIN");
          if (creds) {
            login(creds, admin);
          }
        }}
        options={{
          method: {
            button: {
              text: "Log Into Wallet",
              render: () => (
                <LoadingButton
                  onClick={() => {
                     // I CANT GET IT TO LOG
                    console.log("HI");
                  }}
                  loading={false}
                  loadingPosition="end"
                  sx={{ margin: 1 }}
                  variant="contained"
                  fullWidth
                ></LoadingButton>
              ),
            },
          },
        }}
      />

Hi @rikotacards ,

Thanks for pointing this out! As you discovered, the library does not support custom onClick handlers at this time. I’ll need to think about how to best add support for this in a future release

1 Like

Thanks!
and the only work around I can find is just to wrap the damlHubLogin component with a div or button in my app, then I do an onClick from there.
But then if I use withToken, that div wraps around the entire text input as well.