Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
60 lines (40 sloc) 1.71 KB
title
setData

Type: object|function
Default: undefined

Setup the content to be rendered into the card.

import Microlink from '@microlink/react'

export default () => (
  <Microlink
    url='https://www.instagram.com/p/Bt6EMQhHHIr/'
    setData={{
      title: 'SENTRY ACTIVATED'
    }}
  />
)

<Microlink url='https://www.instagram.com/p/Bt6EMQhHHIr/' setData={{title: 'SENTRY ACTIVATED' }}/>

By default, the library internally performs a fetch against the Microlink API for getting the data related to the target URL.

However, maybe you are interested in skip this part, especially if you are interacting with Microlink API out of the component, but you want to mount that data, skipping fetching the content again.

In that case, you need to provide setData with the content you have to be mounted. This content need to have the same Microlink API data fields.

Additionally, setData, can be invoked as a function

import Microlink from '@microlink/react'

export default () => (
  <Microlink
    url='https://www.instagram.com/p/Bt6EMQhHHIr/'
    setData={data => ({
      ...data,
      title: 'SENTRY ACTIVATED'
    }})
  />
)

The function receive the data fetched internally as the first argument, and you need to return the data you want to be mounted.

This is specially useful when you want to map missing fields from the Microlink API.

In that case, note title is not replaced since it's detected from the initial data.

You can’t perform that action at this time.