Nominal Pizza Masticator

    react-data-attributes-mixin

    1.0.0 • Public • Published

    react-data-attributes-mixin

    Build Status

    Take data from props and convert it to HTML data-* attributes

    Example

    var DataAttributesMixin = require('react-data-attributes-mixin');
     
    var Example = React.createClass({
     
      mixins: [DataAttributesMixin],
      
      propTypes: {
        data: React.PropTypes.object
      },
      
      getDefaultProps: function() {
        return {
          data: {
            type: 'button',
            location: 'web app',
            fooBar: 'baz'
          }
        };
      },
     
      render: function() {
        var dataAttributes = this.getDataAttributesFromProps();
        return (
          <button {...dataAttributes} />
        );
      }
      
    });

    Output

    <button data-type="button" data-location="web app" data-foo-bar="baz"></button>

    Install

    npm i react-data-attributes-mixin

    DownloadsWeekly Downloads

    10

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • holidayextras
    • hxmarkterry