Slide 41
Slide 41 text
testWidgets('usePrevious', (tester) async {
final result = await buildHook(
(value)
= >
usePrevious(value),
initialProps: 42,
);
await result.rebuild(21);
expect(result.current, 42);
});
testWidgets('usePrevious', (tester) async {
await tester.pumpWidget(
HookBuilder(builder: (context) {
usePrevious(42);
return const SizedBox();
}),
);
await tester.pumpWidget(
HookBuilder(builder: (context) {
usePrevious(21);
return const SizedBox();
}),
);
final element = tester.element(find.byType(HookBuilder));
expect(
element
.toDiagnosticsNode(style: DiagnosticsTreeStyle.offstage)
.toStringDeep(),
equalsIgnoringHashCodes(
'HookBuilder\n'
' │ usePrevious: 42\n'
' └SizedBox(renderObject: RenderConstrainedBox#00000)\n',
),
);
});
ར༻͠ͳ͍ ར༻͢Δ
ΧελϜϑοΫͷঢ়ଶΛߋ৽͢ΔͨΊʹ
UFTUFSQVNQ8JEHFUʹ)PPL#VJMEFSΛຖ
ճ͍ͯͨ͠ͷΛলུͰ͖ɺFYQFDU࣌ͷ
ঢ়ଶऔಘγϯϓϧʹॻ͚Δ
ϥΠϒϥϦΛར༻͢Δ߹