Tags
To change the list of tags use the tags property from <IASContainer> config.
Tag limitations:
- Maximum 100 tags.
- Maximum tag length is 50 characters.
- Each tag must match the tag format below.
Tag format
Each tag must match the following regular expression:
const regExp = /^[\p{L}_\d][\p{L}_\d\-]{0,49}$/u;
- The first character must be a letter (any language), digit, or
_. - Subsequent characters may be letters, digits,
_, or-. - Total length: from 1 to 50 characters.
Valid tags:
| Tag | Why it is valid |
|---|---|
premium | Starts with a letter; only allowed characters |
user_123 | Letters, digits, and _ |
en-US | Hyphen in the middle is allowed |
_internal | May start with _ |
123tag | May start with a digit |
Invalid tags:
| Tag | Why it is invalid |
|---|---|
-premium | Must not start with - |
user name | Spaces are not allowed |
tag.name | . is not allowed |
tag@email | Special characters are not allowed |
"" | Empty string is not allowed |
Example
import { StoryList, IASContainer, StoryListApi } from "@inappstory/react-sdk";
export const App = () => {
const [tags, setTags] = useState<string[]>(['default-tag']);
const storyListRef = useRef<StoryListApi | null>(null);
useEffect(() => {
storyListRef.current?.reload() // Reload stories after tags changed (Optional)
}, [tags])
useEffect(() => {
setTags(['new-tag'])
}, [])
return <IASContainer config={{ apiKey: "{projectToken}", tags }}>
<StoryList ref={storyListRef} feed="default" />
</IASContainer>
Exceptions
When passing tags in <IASContainer> config or updating them at runtime, the following errors may be thrown:
IasTagsCountError
Thrown when the number of tags exceeds the limit of 100.
IasTagsLengthError
Thrown when a tag exceeds the maximum length of 50 characters.