Skip to content

How can I get the Key of the custom component when it is rendered? #34

Answered by optimajet
azrlucky asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @azrlucky,

Of course you can. To do this, you need to use the useComponentData hook (https://formengine.io/documentation/api-reference/@react-form-builder/core/functions/useComponentData).

The key property can be found here - https://formengine.io/documentation/api-reference/@react-form-builder/core/classes/ComponentData#key.

const VerifiedByControl = (props: any) => {
  const componentData = useComponentData()
  console.log('componentData', componentData.key);

  console.log('VerifiedByControl', props);
  return (
    <div className={props.className}>
      <VerifiedByCode value={props.value} onChange={props.onChange} />
    </div>
  );
};

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by azrlucky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants