diff --git a/ppx/reason_react_ppx.ml b/ppx/reason_react_ppx.ml index df87542e0..8823c52e0 100644 --- a/ppx/reason_react_ppx.ml +++ b/ppx/reason_react_ppx.ml @@ -647,10 +647,8 @@ let jsxMapper = let expr = mapper#expression ctxt expr in match expr.pexp_desc with | Pexp_fun (Labelled "key", _, _, _) | Pexp_fun (Optional "key", _, _, _) -> - raise - (Invalid_argument - "Key cannot be accessed inside of a component. Don't worry - you \ - can always key a component from its parent!") + Location.raise_errorf ~loc:expr.pexp_loc + ("~key cannot be accessed from the component props. Please set the key where the component is being used.") | Pexp_fun ( ((Optional label | Labelled label) as arg), default,