How to use Polymer in ReactJS?

Technology CommunityCategory: ReactHow to use Polymer in ReactJS?
VietMX Staff asked 3 years ago

Yes, it is possible. You need to follow below steps 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";
    }
});
  1. 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">
  1. 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;