Any idea why this would work fine:
[:button {:on-click #(save-form acct)} "Save"]
while this would generate a react error:
[:input {:type "button"} "Save"]
of the type:
' input is a void element tag and must neither have children
nor use dangerouslySetInnerHTML
.'
Because <input>
and <button>
are different HTML elements.
You want to either make “Save” into a placeholder attribute on the input, or else add a label
element to contain the “Save” text.
ok, thanks!
Just in case - according to MDN, it's the value
attribute, not the placeholder
.
Either way, it's better to use :button
.
That depends on what you want “Save” to function as. If you set value
to be “Save,” then it will change if you edit the text in the input, but if you want “Save” to function as a label when the input is empty, then you want to assign it to the placeholder
attribute.
What text in what input? <input type="button">
will be rendered as a button, there's nothing editable there.
Oh, true, I was thinking of text inputs.
Skimmed right over the {:type "button"}
bit, derp 🤦