This question is a bit popular but Im not having such luck. Im mostly a backend person so Im learning as I go along.
I have a cookie named connect.sid
and v
Full example using the react-cookie v2.
You need to wrap your root component in and also the individual components where you want to access the cookies in withCookies(..). The cookies are then part of props.
client.js:
import {CookiesProvider} from "react-cookie";
App.js:
import React from "react";
import {withCookies} from 'react-cookie';
class App extends React.Component {
render() {
const {cookies} = this.props;
return {cookies.get('mycookie')}
}
}
export default withCookies(App);