Skip to content

Commit

Permalink
fix: remove defaultprops (#137)
Browse files Browse the repository at this point in the history
Since defaultprops is going to be deprecated, these changes eliminate
its use and use the javascript default params.

`Warning: AdvertisingSlot: Support for defaultProps will be removed from
function components in a future major release. Use JavaScript default
parameters instead.`
  • Loading branch information
CristianDeluxe authored Jul 10, 2024
1 parent 84af1a4 commit 7771da4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
14 changes: 7 additions & 7 deletions src/components/AdvertisingProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ export default class AdvertisingProvider extends Component {
super(props);
this.initialize();

const { config, active = true } = props;

this.state = {
activate: this.advertising.activate.bind(this.advertising),
config: this.props.config,
config,
isInitialSetupComplete: false,
};

this.active = active;
}

async componentDidMount() {
if (this.advertising.isConfigReady() && this.props.active) {
if (this.advertising.isConfigReady() && this.active) {
await this.advertising.setup();
// eslint-disable-next-line react/no-did-mount-set-state
this.setState({ isInitialSetupComplete: true });
Expand All @@ -31,7 +35,7 @@ export default class AdvertisingProvider extends Component {
return;
}

const { config, active } = this.props;
const { config, active = true } = this.props;
const isConfigReady = this.advertising.isConfigReady();

// activate advertising when the config changes from `undefined`
Expand Down Expand Up @@ -113,7 +117,3 @@ AdvertisingProvider.propTypes = {
})
),
};

AdvertisingProvider.defaultProps = {
active: true,
};
6 changes: 1 addition & 5 deletions src/components/AdvertisingSlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function AdvertisingSlot({
style,
className,
children,
customEventHandlers,
customEventHandlers = {},
...restProps
}) {
const observerRef = useRef(null);
Expand Down Expand Up @@ -70,8 +70,4 @@ AdvertisingSlot.propTypes = {
customEventHandlers: PropTypes.objectOf(PropTypes.func).isRequired,
};

AdvertisingSlot.defaultProps = {
customEventHandlers: {},
};

export default AdvertisingSlot;

0 comments on commit 7771da4

Please sign in to comment.