Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form re-renders more than it should #196

Open
atoi opened this issue May 2, 2023 · 0 comments
Open

Form re-renders more than it should #196

atoi opened this issue May 2, 2023 · 0 comments

Comments

@atoi
Copy link

atoi commented May 2, 2023

Using the following code I get:

  • 4 render messages on page load
  • another 2 when I enter the first character into the input
  • another 2 when I clear the input

What do I do wrong? Or is it the intended behavior and I just have to learn to live with that?

P.S. No, this is not the "1 server + 1 client log" case. I counted only the client logs.

import { z } from 'zod';
import {
  Form as FrameworkForm,
  useActionData,
  useNavigation,
  useSubmit,
} from '@remix-run/react';
import { createForm } from 'remix-forms';

const Form = createForm({
  component: FrameworkForm,
  useActionData,
  useNavigation,
  useSubmit,
});

const schema = z.object({ test: z.string() });

export default function Test() {
  return (
    <Form schema={schema}>
      {({ Field, Errors, Button }) => {
        console.log('RENDER FORM');
        return (
          <>
            <Field name="test" />
            <Errors />
            <Button />
          </>
        );
      }}
    </Form>
  );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant