Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gabrielbs/react-content-preview

Repository files navigation

React Content Preview

Preview websites anyway you want using https://apileap.com/

Demo

Usage

<ContentPreview
 url='http://www.twitch.tv'
 useCached={ true }
 linkTo={(props) => (
 <a
 onMouseEnter={() => props.getPreview()}
 onMouseLeave={() => props.cleanPreview()}
 href={props.url}>
 preview
 </a>
 )}
 loader={(props) => (
 <div>loading...</div>
 )}
 previewContainer={(props) => (
 <div className='preview-container'>
 <img src={props.previewImg} className='preview-container__img' />
 </div>
 )}
/>

Running example locally

npm run dev

Then access your localhost on port 9000 http://localhost:9000

Props

  • url: PropTypes.string,

A string with the site URL to preview

  • linkTo: PropTypes.func,

A render prop function with getPreview() and cleanPreview() functions

  • previewContainer: PropTypes.func,

A render prop function with the generated printscreen image available on previewImg property

  • loader: PropTypes.func,

A render prop function triggered when is loading

  • proxy: PropTypes.string,

A optional proxy URL to prevent CORS errors. The default value is https://cors-anywhere.herokuapp.com/

  • errorMessage: PropTypes.string

A error message in case of failure on fetch

About

A simple component for preview content of a url

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

AltStyle によって変換されたページ (->オリジナル) /