Skip to content

add custom className support for the top level element #208

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

Open
wants to merge 2 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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ export default GoogleApiWrapper({
})(MapContainer)
```

If you want a custom class for the top level 'div'

```javascript
export default GoogleApiWrapper({
apiKey: (YOUR_GOOGLE_API_KEY_GOES_HERE),
wrapperClassName: 'my-custom-css-class'
})(MapContainer)
```

## Sample Usage With Lazy-loading Google API:

```javascript
Expand Down
4 changes: 3 additions & 1 deletion src/GoogleApiComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export const wrapper = input => WrappedComponent => {
// Store information about loading container
this.LoadingContainer =
options.LoadingContainer || DefaultLoadingContainer;
// add custom className to the top div
this.wrapperClassName = options.wrapperClassName || '';
}

onLoad(err, tag) {
Expand All @@ -116,7 +118,7 @@ export const wrapper = input => WrappedComponent => {
});

return (
<div>
<div className={this.wrapperClassName}>
<WrappedComponent {...props} />
<div ref="map" />
</div>
Expand Down