How to use the react-cookie.load function in react-cookie

To help you get started, we’ve selected a few react-cookie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github huhulab / react-frontend-boilerplate / src / component / App.jsx View on Github external
render() {
    console.log('App.props:', this.props);

    if (cookie.load(tokenKey) === undefined) {
      console.log('X-Token is missing!');
      /* message.error('请先登录系统!');
         this.history.pushState(null, '/signin'); */
    }

    console.log('current user:', this.state.user);
    const navMenu = this.state.user ?  : '';
    return (
      <div>
        <div>
          
          {navMenu}
          <div>
            {this.props.children}
          </div>
        </div></div>
github quran / quran.com-frontend / src / scripts / stores / UserStore.js View on Github external
rehydrate(state) {
    this.options = state.options;
    this.lastVisit = state.lastVisit;
    this.isFirstTime = state.isFirstTime;
    this.version = state.version;

    // TODO: Don't call this everytime.
    if (reactCookie.load('isFirstTime') !== state.isFirstTime) {
      reactCookie.save('isFirstTime', state.isFirstTime);
    }

    if (reactCookie.load('version') !== state.version) {
      reactCookie.save('version', state.version.replace(/\"/g, '').replace(/\\/g, ''));
    }
  }
github joshuaslate / mern-starter / client / src / index.js View on Github external
import { AUTH_USER } from './actions/types';

// Import stylesheets
import './public/stylesheets/base.scss';

// Initialize Google Analytics
ReactGA.initialize('UA-000000-01');

function logPageView() {
  ReactGA.pageview(window.location.pathname);
}

const createStoreWithMiddleware = applyMiddleware(reduxThunk)(createStore);
const store = createStoreWithMiddleware(reducers);

const token = cookie.load('token');

if (token) {
  // Update application state. User has token and is probably authenticated
  store.dispatch({ type: AUTH_USER });
}

ReactDOM.render(
  
    
  ,
  document.querySelector('.wrapper'));
github lifechurch / melos / app / standalone / Bible / main.js View on Github external
}
			},
			routing: {
				location: {
					query
				}
			}
		} = currentState)
	} catch (ex) {
		isInitialLoad = true
	}

	let nextUsfm = `${nextBook}.${nextChapter}`
	if (!nextVersion) { nextVersion = cookie.load('version') || '1' }
	if (!nextChapter) {
		nextUsfm = (cookie.load('last_read') || 'JHN.1').split('.').slice(0, 2).join('.')
	}

	let parallelVersion
	window.location.search.replace('?', '').split('&').forEach((kvPair) => {
		const [ key, value ] = kvPair.split('=')
		if (key.toLowerCase() === 'parallel') {
			parallelVersion = parseInt(value.toString(), 10)
		}
	})

	const hasVersionChanged = isInitialLoad || (currentVersion ? (nextVersion.toString() !== currentVersion.toString()) : true)
	const hasChapterChanged = isInitialLoad || hasVersionChanged || (nextUsfm ? (nextUsfm.toLowerCase() !== currentUsfm.toLowerCase()) : true)
	const hasParallelVersionChanged = isInitialLoad || ('parallel' in query && !!parallelVersion && (parallelVersion !== currentParallelVersionId))

	if (!hasVersionChanged && !hasChapterChanged && !hasParallelVersionChanged && !force) {
		callback()
github service-bot / servicebot / views / components / elements / modals / modal-payment-setup.jsx View on Github external
render () {
        let self = this;
        let pageName = "Payment Setup";
        let icon = "fa-credit-card-alt";
        let spk = cookie.load("spk");

        if(self.props.justPayment) {
            return(
                
                    <div>
                        <div>
                            <div>
                                <div>
                                    {self.state.form === 'credit_card' &amp;&amp;
                                    <div></div>
                                    }
                                </div>
                            </div>
                        </div>
                    </div>
github joshuaslate / mern-starter / client / src / actions / index.js View on Github external
export function putData(action, errorType, isAuthReq, url, dispatch, data) {
  const requestUrl = API_URL + url;
  let headers = {};

  if (isAuthReq) {
    headers = { headers: { Authorization: cookie.load('token') } };
  }

  axios.put(requestUrl, data, headers)
  .then((response) => {
    dispatch({
      type: action,
      payload: response.data,
    });
  })
  .catch((error) => {
    errorHandler(dispatch, error.response, errorType);
  });
}
github service-bot / servicebot / views / components / elements / modals / modal-manage-cancellation.jsx View on Github external
constructor(props){
        super(props);
        let uid = cookie.load("uid");
        let username = cookie.load("username");
        let serviceInstance = this.props.myInstance;
        this.state = {  loading: false,
                        uid: uid,
                        email: username,
                        serviceInstance: serviceInstance,
                        undo_cancel_url: false,
                        confirm_cancel_url: false,
                        reject_cancel_url: false,
                        current_modal: 'model_undo_cancel',
        };
        this.onUndoCancel = this.onUndoCancel.bind(this);
        this.onConfirmCancel = this.onConfirmCancel.bind(this);
        this.onRejectCancel = this.onRejectCancel.bind(this);
    }
github mendersoftware / gui / src / js / components / deployments / deployments.js View on Github external
_refreshDeployments: function() {
    this._refreshInProgress();
    this._refreshPending();
    this._refreshPast();

    if (this.state.showHelptips && !cookie.load(this.state.user.id+'-onboarded') && cookie.load(this.state.user.id+'-deploymentID')) {
      this._isOnBoardFinished(cookie.load(this.state.user.id+'-deploymentID'));
    }
  },
  _refreshInProgress: function(page, per_page) {
github systemaccounting / mxfactorial / app / axios-client-instance.js View on Github external
clientInstance.interceptors.request.use((config) => {
  const token = cookie.load('token');
  if (token) {
    config.headers = assign(config.headers, {
      'Authorization': token
    });
  }
  return config;
});
github service-bot / servicebot / views / components / elements / modals / modal-invoice.jsx View on Github external
constructor(props){
        super(props);
        let uid = cookie.load("uid");
        let username = cookie.load("username");
        this.state = {  loading: true,
            nextInvoice : false,
            currentUser: false,
            url: `/api/v1/invoices/upcoming/${uid}`,
            uid: uid,
            email: username,
        };
        this.fetchNextInvoice = this.fetchNextInvoice.bind(this);
    }