Giter VIP home page Giter VIP logo

react-codepen-embed's Introduction

react-codepen-embed

React component for embedding pens from Codepen.io

Installation

#using npm cli
npm install --save react-codepen-embed

#using yarn
yarn add react-codepen-embed

Usage

import React from "react";
import Codepen from "react-codepen-embed";

const CodepenEmbedded = () => {
  return <Codepen hash="JyxeVP" user="shettypuneeth" />;
};

Component Props

Property Type Required Default Description
hash string true Id of the pen to embed
user string true Codepen username
height number false 300 Height of the pen
loader element false Loader to render while the pen is being embedded or errors out
defaultTab string false css,result Default tab to display
themeId string false dark Theme for the pen
preview boolean false true Make the preview "Click-to-Load"
editable boolean false false Can edit code
title string false Title of the pen

API

Props.loader

Compenent to render when the pen is being embedded or when it errors.

<Codepen
  hash="JyxeVP"
  user="shettypuneeth"
  loader={() => <div>Loading...</div>}
/>

If the embed fails then the loader component will receive an error prop

const Loading = props => {
  if (props.error) {
    return <div>Error</div>;
  }
  return <div>Loading...</div>;
};

react-codepen-embed's People

Contributors

casperiv0 avatar chini5ko avatar dependabot[bot] avatar sebaiturravaldes avatar shettypuneeth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-codepen-embed's Issues

FunctionComp.defaultProps is deprecated in React 18

Description

This issue is based on this issue

The error that happens when using react-codepen-embed with React 18

Warning: ReactCodepen: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead

The root of the problem:

ReactCodepen.defaultProps = {
defaultTab: 'css,result',
height: 300,
preview: true,
editable: false,
themeId: 'dark',
version: 2,
};

Links to React PR and ESLint change:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.