Skip to content

Commit 670d9c4

Browse files
committed
remove css import function
1 parent 6aba141 commit 670d9c4

File tree

3 files changed

+16
-21
lines changed

3 files changed

+16
-21
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ Example:
5050
```jsx
5151
// ES6
5252
import ReactMapboxGl, { Layer, Feature } from 'react-mapbox-gl';
53+
import 'mapbox-gl/dist/mapbox-gl.css';
5354

5455
// ES5
5556
var ReactMapboxGl = require('react-mapbox-gl');
5657
var Layer = ReactMapboxGl.Layer;
5758
var Feature = ReactMapboxGl.Feature;
59+
require('mapbox-gl/dist/mapbox-gl.css');
5860

5961
const Map = ReactMapboxGl({
6062
accessToken:

src/__tests__/map.test.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ describe('Map', () => {
3131
});
3232

3333
it('Should render the map correctly', () => {
34-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
34+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
3535
mount(<MapboxMap style="" />);
3636
});
3737

3838
it('Should call fitBounds with the right parameters', () => {
3939
const fitBoundsValues: FitBounds = [[0, 1], [2, 3]];
4040
const fitBoundsOptions = { linear: true };
41-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
41+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
4242

4343
mount(
4444
<MapboxMap
@@ -58,7 +58,7 @@ describe('Map', () => {
5858
const fitBoundsValues: FitBounds = [[0, 1], [2, 3]];
5959
const fitBoundsOptions = { offset: [150, 0] as [number, number] };
6060
const newFitBoundsOptions = { offset: [0, 0] };
61-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
61+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
6262

6363
const wrapper = mount(
6464
<MapboxMap
@@ -82,7 +82,7 @@ describe('Map', () => {
8282

8383
it('Should calc the center from fitbounds if center is not given', () => {
8484
const fitBoundsValues: FitBounds = [[0, 3], [2, 9]];
85-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
85+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
8686

8787
mount(<MapboxMap style="" fitBounds={fitBoundsValues} />);
8888

@@ -92,7 +92,7 @@ describe('Map', () => {
9292
});
9393

9494
it('Should listen onStyleLoad event', () => {
95-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
95+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
9696

9797
mount(<MapboxMap style="" onStyleLoad={jest.fn()} />);
9898

@@ -102,7 +102,7 @@ describe('Map', () => {
102102
it('Should update the map center position', () => {
103103
const flyTo = jest.fn();
104104
const center = [3, 4];
105-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
105+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
106106

107107
const wrapper = mount(<MapboxMap style="" center={[1, 2]} />);
108108

@@ -123,7 +123,7 @@ describe('Map', () => {
123123
const maxBoundsProps = [[1, 0], [0, 1]];
124124
const mockMaxBounds = jest.fn();
125125

126-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
126+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
127127
const wrapper = mount(<MapboxMap style="" />);
128128
wrapper.setState({
129129
map: {
@@ -139,7 +139,7 @@ describe('Map', () => {
139139

140140
// Handling zoom prop
141141
it('Should not update zoom when using same reference equality', () => {
142-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
142+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
143143
const flyTo = jest.fn();
144144
const zoom: [number] = [3];
145145

@@ -158,7 +158,7 @@ describe('Map', () => {
158158

159159
it('Should update the zoom on broken reference equality', () => {
160160
const flyTo = jest.fn();
161-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
161+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
162162

163163
const wrapper = mount(<MapboxMap style="" zoom={[1]} />);
164164

@@ -175,7 +175,7 @@ describe('Map', () => {
175175

176176
// Handling bearing prop
177177
it('Should not update bearing when using same reference equality', () => {
178-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
178+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
179179
const flyTo = jest.fn();
180180
const bearing: [number] = [3];
181181

@@ -194,7 +194,7 @@ describe('Map', () => {
194194

195195
it('Should update the bearing on broken reference equality', () => {
196196
const flyTo = jest.fn();
197-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
197+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
198198

199199
const wrapper = mount(<MapboxMap style="" bearing={[1]} />);
200200

@@ -211,7 +211,7 @@ describe('Map', () => {
211211

212212
// Handling pitch prop
213213
it('Should not update pitch when using same reference equality', () => {
214-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
214+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
215215
const flyTo = jest.fn();
216216
const pitch: [number] = [3];
217217

@@ -230,7 +230,7 @@ describe('Map', () => {
230230

231231
it('Should update the pitch on broken reference equality', () => {
232232
const flyTo = jest.fn();
233-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
233+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
234234

235235
const wrapper = mount(<MapboxMap style="" pitch={[1]} />);
236236

@@ -246,7 +246,7 @@ describe('Map', () => {
246246
});
247247

248248
it('Should pass animation options and flyTo options', () => {
249-
const MapboxMap = ReactMapboxGl({ accessToken: '', injectCSS: false });
249+
const MapboxMap = ReactMapboxGl({ accessToken: '' });
250250
const flyTo = jest.fn();
251251
const zoom: [number] = [3];
252252
const flyToOptions = {

src/map.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export interface FactoryParameters {
9797
refreshExpiredTiles?: boolean;
9898
failIfMajorPerformanceCaveat?: boolean;
9999
bearingSnap?: number;
100-
injectCSS?: boolean;
101100
transformRequest?: RequestTransformFunction;
102101
antialias?: boolean;
103102
}
@@ -141,15 +140,9 @@ const ReactMapboxFactory = ({
141140
refreshExpiredTiles = true,
142141
failIfMajorPerformanceCaveat = false,
143142
bearingSnap = 7,
144-
injectCSS = true,
145143
antialias = false,
146144
transformRequest
147145
}: FactoryParameters) => {
148-
if (injectCSS) {
149-
// tslint:disable-next-line:no-submodule-imports
150-
require('mapbox-gl/dist/mapbox-gl.css');
151-
}
152-
153146
return class ReactMapboxGl extends React.Component<Props & Events, State> {
154147
public static defaultProps = {
155148
// tslint:disable-next-line:no-any

0 commit comments

Comments
 (0)