Skip to content

Commit 0636054

Browse files
committed
Bug fixes
1 parent a0f2a74 commit 0636054

File tree

5 files changed

+20
-48
lines changed

5 files changed

+20
-48
lines changed

README.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,13 @@ $ npm install --save topcoder-react-utils
1111

1212
You are done if you will use only components and utilities provided by this
1313
package. If you are to use configurations, you must also install peer
14-
dependencies. If you like to explicitly add them to the `package.json` of your
15-
project do
14+
dependencies:
1615
```
1716
$ npm install -g install-peerdeps
1817
$ install-peerdeps topcoder-react-utils
1918
```
2019

21-
Alternatively, you can do
22-
```
23-
$ npm install --save install-peerdeps
24-
```
25-
26-
then add to your `package.json` the following script:
27-
```json
28-
"postinstall": "install-peerdeps -S topcoder-react-utils"
29-
```
30-
31-
Now, in both cases, `$ npm install` will install all necessary dependencies, but
32-
in the second case they won't be stored into your `package.json`.
20+
Peer dependencies will be also stored into `package.json` of your project, thus future invokations of `npm install` will automatically install them, and you won't need to use `install-peerdeps` as long as you don't update `topcoder-react-utils` version.
3321

3422
### Configurations
3523
- [**Babel Configurations**](docs/babel-config.md) — Standard configurations

config/babel/node-ssr.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ config.plugins = config.plugins.concat([
1717
['css-modules-transform', cssModulesTransformPluginOps],
1818
]);
1919

20+
const envPresetsOps
21+
= config.presets.find(x => x[0] === 'env')[1];
22+
2023
const moduleResolverPluginOps
2124
= config.plugins.find(x => x[0] === 'module-resolver')[1];
2225

2326
moduleResolverPluginOps.transformFunctions = ['resolveWeak'];
2427

2528
switch (process.env.BABEL_ENV) {
2629
case 'development':
30+
envPresetsOps.modules = 'commonjs';
2731
_.pull(config.plugins, 'react-hot-loader/babel');
2832
cssModulesTransformPluginOps.generateScopedName = '[path][name]___[local]';
2933
break;

config/babel/webpack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const config = {
3232

3333
switch (process.env.BABEL_ENV) {
3434
case 'development':
35+
envPresetOps.modules = false;
3536
reactCssModulesPluginOps.generateScopedName = '[path][name]___[local]';
3637
config.plugins.push('react-hot-loader/babel');
3738
break;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "topcoder-react-utils",
3-
"version": "0.0.19",
3+
"version": "0.0.21",
44
"description": "Topcoder collection of generic ReactJS components and utils",
5-
"main": "index.js",
5+
"main": "dist/index.js",
66
"engines": {
77
"node": "~8.9.4",
88
"npm": "~5.6.0"

src/GenericLink.jsx

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,20 @@
88

99
/* global document, window */
1010

11+
import _ from 'lodash';
1112
import PT from 'prop-types';
1213
import React from 'react';
1314
import Url from 'url-parse';
1415

1516
export default function GenericLink(props) {
1617
const {
17-
activeClassName,
18-
activeStyle,
1918
children,
2019
className,
2120
enforceA,
22-
exact,
23-
isActive,
24-
location,
2521
onClick,
2622
onMouseDown,
2723
openNewTab,
28-
replace,
2924
routerLinkType,
30-
strict,
3125
to,
3226
} = props;
3327
/* Renders the link as <a> element if either opted explicitely, or the link
@@ -45,15 +39,17 @@ export default function GenericLink(props) {
4539
);
4640
}
4741

42+
const linkProps = _.omit(props, [
43+
'children',
44+
'enforceA',
45+
'openNewTab',
46+
'routerLinkType',
47+
]);
48+
4849
/* Otherwise we render the link as React Router's Link or NavLink element. */
4950
return React.createElement(
5051
routerLinkType, {
51-
activeClassName,
52-
activeStyle,
53-
className,
54-
exact,
55-
isActive,
56-
location,
52+
...linkProps,
5753
onClick: (e) => {
5854
/* If a custom onClick(..) handler was provided we execute it. */
5955
if (onClick) onClick(e);
@@ -69,45 +65,28 @@ export default function GenericLink(props) {
6965
* references the same page we are already in. */
7066
} else window.scroll(0, 0);
7167
},
72-
onMouseDown,
73-
replace,
74-
strict,
75-
to,
76-
},
68+
}, children,
7769
);
7870
}
7971

8072
GenericLink.defaultProps = {
81-
activeClassName: null,
82-
activeStyle: null,
8373
children: null,
8474
className: null,
8575
enforceA: false,
86-
exact: false,
87-
isActive: null,
88-
location: null,
8976
onClick: null,
9077
onMouseDown: null,
9178
openNewTab: false,
9279
replace: false,
93-
strict: false,
9480
to: '',
9581
};
9682

9783
GenericLink.propTypes = {
98-
activeClassName: PT.string,
99-
activeStyle: PT.string,
10084
children: PT.node,
10185
className: PT.string,
10286
enforceA: PT.bool,
103-
exact: PT.bool,
104-
isActive: PT.func,
105-
location: PT.shape(),
10687
onClick: PT.func,
10788
onMouseDown: PT.func,
10889
openNewTab: PT.bool,
109-
replace: PT.bool,
110-
routerLinkType: PT.element.isRequired,
111-
strict: PT.bool,
90+
routerLinkType: PT.func.isRequired,
11291
to: PT.oneOfType([PT.object, PT.string]),
11392
};

0 commit comments

Comments
 (0)