Renders dynamic content by replacing placeholders in the given text with passed react components. Uses %1$s, %2$s, etc. as placeholders in the text and replaces them with the corresponding component from the tokens array.

Parameters:
NameTypeDescription
propsobject

The options object.

Properties
NameTypeDescription
textstring

The text containing placeholders.

tokensArray

The array of tokens to be used for replacement.

Since
  • 3.1.1
Returns:
  • The JSX element with injected components.
Type: 
React.ReactNode
Example
import Link from '@gravityforms/components/react/admin/elements/Link';
import Text from '@gravityforms/components/react/admin/elements/Text';
import { SprintR } from '@gravityforms/react-utils';

<SprintR
	text="Hey there replace this: %1$s and this: %2$s and this with the first component again: %1$s"
	tokens={ [
		{
			component: Text,
			props: {
				content: "I replace both %1$s",
				customClasses: [ 'gform-example-text' ],
				size: 'text-xs',
				tagName: 'span',
			},
		},
	    {
			component: Link,
			props: {
				content: "I replace %2$s",
				customClasses: [ 'gform-example-link' ],
				size: 'text-xs',
				tagName: 'span',
			},
		},
	] }
/>