Sugar
Sugar copied to clipboard
Example of Sugar with create-react-app
With the popularity of React (and create-react-app) these days, it would be great to see some examples of Sugar using it with webpack, es6 imports, etc.
Awesome idea... will work on this soon!
Thanks for the quick response here, Andrew! If you wouldn't mind giving a basic example even just in the comments here, I'd be happy to fill in implementation details. Minimally this thread should surface when people start searching for React with Sugar.
Something like this?
npm install sugar
import Sugar from "sugar";
Sugar.Date.create('next Friday'); //wishful thinking..this doesn't seem to work
Btw, I just tested several js date parsing libs. Sugar's appears to be the best. Great work and thank you for building this!
Here's a workaround in the meantime that plays nicely with Create React App:
Include the Sugar lib in your index.html
<script src="https://cdnjs.cloudflare.com/ajax/libs/sugar/2.0.4/sugar.min.js"></script>
Then, inside of Create React App, reference Sugar from the global, window
object.
window.Sugar.Date.create('next Friday');
Sorry for taking ages on this. The next major version of Sugar will be a complete refactor of the skeleton from the ground up to use ES6 imports. For now import * as Sugar from 'sugar'
should work for you... let me know if it doesn't.
Is there updated docs on how to use Sugar dates with React?