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

I can’t seem to get the form to render correctly with formRender #1597

Open
clinicamaniladev opened this issue Jan 28, 2025 · 0 comments
Open

Comments

@clinicamaniladev
Copy link

it outputs "Form Rendered" in the browser console but nothing actually shows

FormRender.tsx
import './jQuery';

import 'jquery-ui-sortable';
import 'formBuilder/dist/form-render.min.js';
import { useEffect, useRef } from 'react';

declare global {
  interface JQuery {
    formRender(options?: any): any;
  }
}

const data = [
  {
    type: 'number',
    required: false,
    label: 'Number',
    className: 'form-control',
    name: 'number-1738036369201-0',
    access: false,
    subtype: 'number',
  },
  {
    type: 'paragraph',
    subtype: 'p',
    label: 'Paragraph',
    access: false,
  },
];

const FormRender = () => {
  const fb = useRef(null);
  const isInitialized = useRef(false);

  useEffect(() => {
    if (!isInitialized.current) {
      if (fb.current) {
        $(fb.current).formRender({
          dataType: 'json',
          formData: JSON.stringify(data),
        });
      }
      isInitialized.current = true;
    }

    return () => {
      if (fb.current) {
        $(fb.current).empty();
      }
    };
  }, []);

  return (
    <div className='bg-gray-100 p-4'>
      <div className='bg-white p-4 rounded-md shadow-md'>
        <p className='mb-3'>FORM RENDER</p>
        <div className='w-full h-full bg-red-500'></div>
        <div id='fb-render' ref={fb}></div>
      </div>
    </div>
  );
};

export default FormRender;

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