docs/warning: fix <ActionForm/> docs and add runtime warning for incorrect encodings (#1360)

This commit is contained in:
Greg Johnston 2023-07-15 19:09:03 -04:00 committed by GitHub
parent 8e68699435
commit 5af2f4e98d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -342,8 +342,7 @@ fn current_window_origin() -> String {
///
/// ## Encoding
/// **Note:** `<ActionForm/>` only works with server functions that use the
/// default `Url` encoding or the `GetJSON` encoding, not with `CBOR` or other
/// encoding schemes. This is to ensure that `<ActionForm/>` works correctly
/// default `Url` encoding. This is to ensure that `<ActionForm/>` works correctly
/// both before and after WASM has loaded.
#[cfg_attr(
any(debug_assertions, feature = "ssr"),
@ -493,6 +492,19 @@ where
});
});
let class = class.map(|bx| bx.into_attribute_boxed(cx));
#[cfg(debug_assertions)]
{
if I::encoding() != server_fn::Encoding::Url {
leptos::warn!(
"<ActionForm/> only supports the `Url` encoding for server \
functions, but {} uses {:?}.",
std::any::type_name::<I>(),
I::encoding()
);
}
}
let mut props = FormProps::builder()
.action(action_url)
.version(version)