iansinnott / react-string-replace

A simple way to safely do string replacement with React components
MIT License
652 stars 56 forks source link

Possible use this library with ES6 Imports? #19

Closed Jenan closed 7 years ago

Jenan commented 7 years ago

Hello,

is it possible use this library with ES6 Imports?

I have tried something like this:

import { reactStringReplace} from "react-string-replace"; But it doesn't work because I get error reactStringReplace is not a function

How can I fix this? :) Thank you.

iansinnott commented 7 years ago

Yup, that should work fine, but the function is the default export not a named export. So try:

import reactStringReplace from "react-string-replace";
iansinnott commented 7 years ago

Check out this example for a working example: https://github.com/iansinnott/react-string-replace/blob/master/example/index.js#L3

Note that this module is NOT written in ES6, but if you are using bundler like Webpack it should still be able to handle it.