Skip to main content

Tags

To change the list of tags use the tags property from <IASContainer> config.

Tag limitations:

  1. Maximum 100 tags.
  2. Maximum tag length is 50 characters.
  3. 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:

TagWhy it is valid
premiumStarts with a letter; only allowed characters
user_123Letters, digits, and _
en-USHyphen in the middle is allowed
_internalMay start with _
123tagMay start with a digit

Invalid tags:

TagWhy it is invalid
-premiumMust not start with -
user nameSpaces are not allowed
tag.name. is not allowed
tag@emailSpecial 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.