From 3137b63b120cb8573daac693f5b4ae8f58f7ade4 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Tue, 21 Apr 2015 21:45:21 -0400 Subject: [PATCH] add docs about infinite loop pitfall --- docs/mithril.component.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/mithril.component.md b/docs/mithril.component.md index 8709d20b..59e8884c 100644 --- a/docs/mithril.component.md +++ b/docs/mithril.component.md @@ -495,7 +495,13 @@ If a component A contains another component B that calls asynchronous services, ### Limitations and caveats -There are a few caveats when nesting components: +One important limitation to be aware of when using components is that you cannot call Mithril's redrawing methods ([`m.startComputation` / `m.endComputation`](mithril.computation.md) and [`m.redraw`](mithril.redraw.md)) from templates. + +In addition, you cannot call `m.request` from templates. + +Doing so will trigger another redraw, which will result in an infinite loop. + +There are a few other technical caveats when nesting components: 1. Nested component views must return either a virtual element or another component. Returning an array, a string, a number, boolean, falsy value, etc will result in an error.