Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Updating all packages within the project to their most up to date versions #36

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
{
"presets": [ "stage-0", "es2015", "react" ],
"plugins": [ "transform-class-properties" ]
"presets": [
"@babel/preset-react",
"@babel/preset-env"
],
"plugins": [
[
"@babel/plugin-syntax-class-properties",
{
"loose": false
}
],
"@babel/plugin-proposal-class-properties"
]
}
36 changes: 36 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# For more information about the properties used in
# this file, please see the EditorConfig documentation:
# http://editorconfig.org/

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2

[*.{yml,json}]
# The indent size used in the `package.json` file cannot be changed
# https://github.com/npm/npm/pull/3180#issuecomment-16336516
indent_size = 2

[*.scss]
indent_size = 2

[*.js]
indent_size = 2

[*.html]
indent_size = 4

[.eslintrc]
indent_size = 2
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
logs
*.log

# JetBrains
.idea/

# Runtime data
pids
*.pid
Expand Down
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: node_js
node_js:
- 'iojs'
- '0.12'
- '0.10'
- '10.14.1'
- '11.3.0'
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# react-async-script-loader
# react-lazy-script-loader

[![Build Status](https://travis-ci.org/leozdgao/react-async-script-loader.svg?branch=master)](https://travis-ci.org/leozdgao/react-async-script-loader) [![npm version](https://badge.fury.io/js/react-async-script-loader.svg)](https://badge.fury.io/js/react-async-script-loader)
[![Build Status](https://travis-ci.org/AndrewLowther/react-async-script-loader.svg?branch=master)](https://travis-ci.org/AndrewLowther/react-async-script-loader) [![npm version](https://badge.fury.io/js/react-lazy-script-loader.svg)](https://badge.fury.io/js/react-lazy-script-loader)

A decorator for script lazy loading on react component.

This is a direct fork from [leozdgao/react-async-script-loader](https://github.com/leozdgao/react-async-script-loader) until dependencies are updated.

## Description

Some component may depend on other vendors which you may not want to load them until you really need them. So here it is, use **High Order Component** to decorate your component and it will handle lazy loading for you, it support parallel and sequential loading.

## Installation

```bash
npm install --save react-async-script-loader
npm install --save react-lazy-script-loader
```

## API
Expand All @@ -38,7 +40,7 @@ You can use it to decorate your component.

```javascript
import React, { Component } from 'react'
import scriptLoader from 'react-async-script-loader'
import scriptLoader from 'react-lazy-script-loader'

class Editor extends Component {
...
Expand Down
16 changes: 16 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Image for use in this project
image: ubuntu

# Commands for the build process
install:
# Install node via NVM
- nvm --version
- nvm install 10.14.1
- nvm use 10.14.1
- yarn install

test_script:
- yarn test

# Turn the build off, as otherwise it will try to build a .net project
build: off
19 changes: 14 additions & 5 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Karma configuration

const webpack = require('webpack')
const webpack = require('webpack');

module.exports = function (config) {
config.set({
Expand Down Expand Up @@ -31,10 +31,19 @@ module.exports = function (config) {
},

webpack: {
mode: 'development',
devtool: 'inline-source-map',
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' }
rules: [
{
test: /\.js$/,
exclude: [
/node_modules/
],
use: {
loader: "babel-loader"
}
}
]
},
plugins: [
Expand Down Expand Up @@ -72,7 +81,7 @@ module.exports = function (config) {

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [ 'PhantomJS' ],
browsers: [ 'ChromeHeadless' ],


// Continuous Integration mode
Expand All @@ -83,4 +92,4 @@ module.exports = function (config) {
// how many browser should be started simultaneous
concurrency: Infinity
})
}
};
65 changes: 34 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,61 @@
{
"name": "react-async-script-loader",
"version": "0.2.3",
"name": "react-lazy-script-loader",
"version": "0.3.2",
"description": "A decorator for script lazy loading on react component",
"main": "lib/index.js",
"private": false,
"scripts": {
"build": "babel src --out-dir lib",
"prepublish": "npm run build",
"test": "karma start"
},
"repository": {
"type": "git",
"url": "git+https://github.com/leozdgao/react-script-loader.git"
"url": "git+https://github.com/andrewlowther/react-async-script-loader.git"
},
"keywords": [
"react",
"reactjs",
"react-component"
],
"author": "leozdgao",
"author": "andrewlowther",
"license": "MIT",
"bugs": {
"url": "https://github.com/leozdgao/react-script-loader/issues"
"url": "https://github.com/AndrewLowther/react-async-script-loader/issues"
},
"homepage": "https://github.com/leozdgao/react-script-loader#readme",
"homepage": "https://github.com/AndrewLowther/react-async-script-loader#readme",
"peerDependencies": {
"react": "^15.0.1 || ^16.0.0"
"react": "^16.0.0"
},
"devDependencies": {
"babel-cli": "^6.1.18",
"babel-eslint": "^4.1.5",
"babel-loader": "~6.2.4",
"babel-plugin-syntax-class-properties": "^6.1.18",
"babel-plugin-transform-class-properties": "^6.1.20",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"babel-preset-stage-0": "^6.1.18",
"chai": "~3.5.0",
"eslint": "^1.9.0",
"karma": "~0.13.22",
"karma-chai": "~0.1.0",
"karma-mocha": "~0.2.2",
"karma-mocha-reporter": "~2.0.0",
"karma-phantomjs-launcher": "~1.0.0",
"karma-sourcemap-loader": "~0.3.7",
"karma-webpack": "~1.7.0",
"mocha": "~2.4.5",
"phantomjs-prebuilt": "~2.1.7",
"prop-types": "~15.5.8",
"react": "^15.0.1",
"@babel/cli": "^7.2.0",
"@babel/core": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.2.1",
"@babel/plugin-syntax-class-properties": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",
"chai": "^4.2.0",
"eslint": "^5.9.0",
"karma": "^3.1.3",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^3.0.5",
"mocha": "^5.2.0",
"phantomjs-prebuilt": "^2.1.16",
"prop-types": "^15.6.2",
"react": "^16.6.3",
"react-addons-test-utils": "^15.0.1",
"react-dom": "^15.0.1",
"webpack": "~1.12.14"
"react-dom": "^16.6.3",
"webpack": "^4.27.1"
},
"dependencies": {
"hoist-non-react-statics": "^1.0.3"
"hoist-non-react-statics": "^3.2.1"
}
}
26 changes: 13 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react'
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import hoistStatics from 'hoist-non-react-statics'
import { newScript, series, noop } from './utils'
import {newScript, series, noop} from './utils'

const loadedScript = []
const pendingScripts = {}
Expand Down Expand Up @@ -69,15 +69,15 @@ const removeFailedScript = () => {

const scriptLoader = (...scripts) => (WrappedComponent) => {
class ScriptLoader extends Component {
static propTypes = {
onScriptLoaded: PropTypes.func
}

static defaultProps = {
onScriptLoaded: noop
}
};

static propTypes = {
onScriptLoaded: PropTypes.func
};

constructor (props, context) {
constructor(props, context) {
super(props, context)

this.state = {
Expand All @@ -88,10 +88,10 @@ const scriptLoader = (...scripts) => (WrappedComponent) => {
this._isMounted = false;
}

componentDidMount () {
componentDidMount() {
this._isMounted = true;
startLoadingScripts(scripts, err => {
if(this._isMounted) {
if (this._isMounted) {
this.setState({
isScriptLoaded: true,
isScriptLoadSucceed: !err
Expand All @@ -104,15 +104,15 @@ const scriptLoader = (...scripts) => (WrappedComponent) => {
})
}

componentWillUnmount () {
componentWillUnmount() {
this._isMounted = false;
}

getWrappedInstance () {
getWrappedInstance() {
return this.refs.wrappedInstance;
}

render () {
render() {
const props = {
...this.props,
...this.state,
Expand Down
Loading