feat: props memoization is more powerful

This commit solves the memoization , properly memoizing properties that don't have any generic parameters. This is a rough heuristic to prevent non-static lifetimes from creeping into props and breaking our minual lifetime management.

Props that have a generic parameter are opted-out of the `partialeq` requirement and props *without* lifetimes must implement partialeq. We're going to leave manual disabling of memoization for future work.
This commit is contained in:
Jonathan Kelley committed 2021-06-22 17:20:54 -04:00
1 parent 7102fe5f98
commit 73047fe956
37 files changed
+877 -977

No files matched your search

+12
View File
@@ -494,10 +494,22 @@ where
/// .finish();
/// ```
pub fn iter_child(mut self, nodes: impl IntoIterator<Item = impl IntoVNode<'a>>) -> Self {
let len_before = self.children.len();
for item in nodes {
let child = item.into_vnode(&self.ctx);
self.children.push(child);
}
let len_after = self.children.len();
if len_after > len_before {
let last_child = self.children.last().unwrap();
if last_child.key().is_none() {
// TODO: Somehow get the name of the component when NodeCtx is being made
const ERR_MSG: &str = r#"Warning: Each child in an array or iterator should have a unique "key" prop.
Check the render method of XXXX.
See fb.me/react-warning-keys for more information. "#;
log::error!("{}", ERR_MSG);
}
}
self
}
}