github gregberge/svgr v6.0.0-alpha.1

latest releases: v8.1.0, v8.0.1, v8.0.0...
pre-release2 years ago

Bug Fixes

Features

BREAKING CHANGES

Templates

Template signature has changed, it is now much more simpler to create custom templates. Also you don't have to do anything specific to use TypeScript in your template. If you need some Babel specific things you have to import it by yourself.

v5.x

const template = (
  { template },
  opts,
  { imports, interfaces, componentName, props, jsx, exports }
) => {
  const plugins = ["jsx"];
  if (opts.typescript) {
    plugins.push("typescript");
  }
  const typeScriptTpl = template.smart({ plugins });
  return typeScriptTpl.ast`${imports}

${interfaces}

function ${componentName}(${props}) {
  return ${jsx};
}
${exports}
  `;
};

module.exports = template;

v6.x

const template = (variables, { tpl }) => {
  return tpl`
${variables.imports};

${variables.interfaces};

const ${variables.componentName} = (${variables.props}) => (
  ${variables.jsx}
);
 
${variables.exports};
`;
};

module.exports = template;

Don't miss a new svgr release

NewReleases is sending notifications on new releases.