Browse Source

fix(gform): context was not loaded

switch back to a functional component
useContext to load context
add proptype
master
Pierre-Louis Guhur 2 years ago
parent
commit
1dc30435ff
  1. 38
      src/components/banner/Gform.jsx

38
src/components/banner/Gform.jsx

@ -1,22 +1,28 @@
/* eslint react/prop-types: 0 */
import React, { Component } from "react";
import React, { useContext } from "react";
import PropTypes from 'prop-types';
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faGoogleDrive } from "@fortawesome/free-brands-svg-icons";
import { AppContext } from "../../AppContext"
class Gform extends Component {
render () {
return (
<a
className={this.props.className}
href={this.context.feedbackForm}
target="_blank"
rel="noopener noreferrer"
>
<FontAwesomeIcon icon={faGoogleDrive} className="mr-2" />
Votre avis nous intéresse !
</a>
);
}
const Gform = (props) => {
const context = useContext(AppContext);
console.log(context);
return (
<a
className={props.className}
href={context.feedbackForm}
target="_blank"
rel="noopener noreferrer"
>
<FontAwesomeIcon icon={faGoogleDrive} className="mr-2" />
Votre avis nous intéresse !
</a>
);
}
Gform.propTypes = {
className: PropTypes.string,
};
export default Gform;
Loading…
Cancel
Save