React troubleshooting
The problem
When passing placement details in a React page, make sure that the same placement is not mistakenly submitted twice - e.g. when the same component event is fired more than once.
This can result in the following error:
Error in TRC.handleLoadResponse : : Cannot set property 'isFeed' of undefined
The solution
A possible solution is to set a flag within your component's state. The following code illustratesΒ the general idea, using a class component.
class YourNiftyComponent extends React.Component {
componentDidMount() {
// Check if flag is 'false':
if (this.state.isPushed === false) {
// If yes...
// a) Pass placement details:
window._taboola = window._taboola || [];
_taboola.push({
mode: "<mode>",
container: "<container_id>", // You must add a <div> container to the page, with a unique ID.
placement: "<placement>",
target_type: "<target_type>",
});
// b) Set flag to 'true':
this.setState({
isPushed: true,
});
}
}
}
Updated over 2 years ago