diff --git a/test/React__test.re b/test/React__test.re index b96e9da6..bfa76985 100644 --- a/test/React__test.re +++ b/test/React__test.re @@ -359,4 +359,54 @@ describe("React", () => { /* We catch the exception here to not populate the error to the toplevel */ () }; + + test( + "Memo and normal components rendering with equal and different props", () => { + let container = getContainer(container); + let root = ReactDOM.Client.createRoot(container); + + module Normal = { + let renders = ref(0); + + [@react.component] + let make = (~a) => { + renders := renders^ + 1; +
{Printf.sprintf("`a` is %s", a) |> React.string}
; + }; + }; + + module Memo = { + let renders = ref(0); + + [@react.component] + let make = + React.memo((~a) => { + renders := renders^ + 1; +
{Printf.sprintf("`a` is %s", a) |> React.string}
; + }); + }; + + act(() => { + ReactDOM.Client.render( + root, +
, + ) + }); + act(() => { + ReactDOM.Client.render( + root, +
, + ) + }); + act(() => { + ReactDOM.Client.render( + root, +
, + ) + }); + + expect(Normal.renders^)->toBe(3); + + expect(Memo.renders^)->toBe(2); + }); });