Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use Polymer inside of React?

I have been using React and look to use Polymer tags inside of React. React does not recognize Polymer tags as React only handles basic DOM tags. Is there a way to add the Polymer tags to React DOM library?

like image 551
Vu Dang Avatar asked Oct 14 '14 16:10

Vu Dang


People also ask

Is polymer a framework or library?

Polymer is an open-source JavaScript library for building web applications using Web Components.

What is the use of polymer JS?

Why Use Polymer. js? It allows to create our own custom elements easily using the HTML, CSS, and JavaScript for adding interactions to the element. It is created by Google that provides cross-browser compatible applications along with the web components.

How does react work inside?

At its very core, React basically maintains a tree for you. This tree is able to do efficient diff computations on the nodes. Think of your HTML code as a tree. In fact, that is exactly how the browser treats your DOM (your rendered HTML on the browser).

What is a React object?

React components has a built-in state object. The state object is where you store property values that belongs to the component. When the state object changes, the component re-renders.


1 Answers

Yes, it is possible.

  1. Create a polymer element.

    <link rel="import" href="../../bower_components/polymer/polymer.html"> 
    Polymer({     is: 'calender-element',     ready: function(){         this.textContent = "I am a calender";     } }); 
  2. Make the polymer component a html tag by importing it in a html page. E.g. import it in the index.html of your react application.

    <link rel="import" href="./src/polymer-components/calender-element.html"> 
  3. Use that element in the jsx file.

    'use strict';  import React from 'react';  class MyComponent extends React.Component{     render(){         return (             <calender-element></calender-element>         );     } }  export default MyComponent; 
like image 136
Sanjeev Avatar answered Sep 27 '22 17:09

Sanjeev