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:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
props | object | The options object. Properties
|
- Since
- 3.1.1
- Source
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',
},
},
] }
/>