@@ -84,15 +84,9 @@ const CascadingDropdownExample = () => {
8484 } ,
8585 } ) ;
8686
87- // Don't render if methods is not ready
88- if ( ! methods || ! methods . handleSubmit ) {
89- return < div > Loading...</ div > ;
90- }
91-
9287 // When country changes, update available states and reset state selection
9388 useOnFormValueChange ( {
9489 name : 'country' ,
95- methods,
9690 onChange : ( value ) => {
9791 const states = statesByCountry [ value ] || [ ] ;
9892 setAvailableStates ( states ) ;
@@ -102,6 +96,11 @@ const CascadingDropdownExample = () => {
10296 } ,
10397 } ) ;
10498
99+ // Don't render if methods is not ready
100+ if ( ! methods || ! methods . handleSubmit ) {
101+ return < div > Loading...</ div > ;
102+ }
103+
105104 return (
106105 < RemixFormProvider { ...methods } >
107106 < form onSubmit = { methods . handleSubmit } className = "w-96" >
@@ -238,32 +237,29 @@ const AutoCalculationExample = () => {
238237 methods . setValue ( 'total' , total . toFixed ( 2 ) ) ;
239238 } ;
240239
241- // Don't render if methods is not ready
242- if ( ! methods || ! methods . handleSubmit ) {
243- return < div > Loading...</ div > ;
244- }
245-
246240 // Recalculate when quantity changes
247241 useOnFormValueChange ( {
248242 name : 'quantity' ,
249- methods,
250243 onChange : calculateTotal ,
251244 } ) ;
252245
253246 // Recalculate when price changes
254247 useOnFormValueChange ( {
255248 name : 'pricePerUnit' ,
256- methods,
257249 onChange : calculateTotal ,
258250 } ) ;
259251
260252 // Recalculate when discount changes
261253 useOnFormValueChange ( {
262254 name : 'discount' ,
263- methods,
264255 onChange : calculateTotal ,
265256 } ) ;
266257
258+ // Don't render if methods is not ready
259+ if ( ! methods || ! methods . handleSubmit ) {
260+ return < div > Loading...</ div > ;
261+ }
262+
267263 return (
268264 < RemixFormProvider { ...methods } >
269265 < form onSubmit = { methods . handleSubmit } className = "w-96" >
@@ -396,15 +392,9 @@ const ConditionalFieldsExample = () => {
396392 } ,
397393 } ) ;
398394
399- // Don't render if methods is not ready
400- if ( ! methods || ! methods . handleSubmit ) {
401- return < div > Loading...</ div > ;
402- }
403-
404395 // Show/hide fields based on delivery type
405396 useOnFormValueChange ( {
406397 name : 'deliveryType' ,
407- methods,
408398 onChange : ( value ) => {
409399 setShowShipping ( value === 'delivery' ) ;
410400 setShowPickup ( value === 'pickup' ) ;
@@ -418,6 +408,11 @@ const ConditionalFieldsExample = () => {
418408 } ,
419409 } ) ;
420410
411+ // Don't render if methods is not ready
412+ if ( ! methods || ! methods . handleSubmit ) {
413+ return < div > Loading...</ div > ;
414+ }
415+
421416 return (
422417 < RemixFormProvider { ...methods } >
423418 < form onSubmit = { methods . handleSubmit } className = "w-96" >
0 commit comments