How to use the react-cookie.save 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 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 LessWrong2 / Lesswrong2 / packages / example-forum / lib / components / common / Newsletter.jsx View on Github external
dismissBanner(e) {
    if (e && e.preventDefault) e.preventDefault();

    this.setState({showBanner: false});

    // set cookie to keep the banner dismissed persistently 
    Cookie.save('showBanner', 'no');
  }
github quran / quran.com-frontend / src / redux / actions / options.js View on Github external
export function setOption(payload) {
  const options = cookie.load('options') || {}; // protect against first timers.

  Object.keys(payload).forEach((option) => {
    options[option] = payload[option];
  });
  cookie.save('options', JSON.stringify(options));

  return {
    type: SET_OPTION,
    payload
  };
}
github cdapio / cdap / cdap-ui / app / cdap / components / Wrangler / TopPanel / WorkspaceModal.js View on Github external
.subscribe((res) => {
        cookie.save('WRANGLER_WORKSPACE', workspaceId);

        WranglerStore.dispatch({
          type: WranglerActions.setWorkspace,
          payload: {
            workspaceId,
            data: res.value,
            headers: res.header
          }
        });
      }, (err) => {
        console.log('err', err);
github lifechurch / melos / nodejs / app / features / EventEdit / features / content / components / ContentTypeReference.js View on Github external
handleVersionChange(event) {
		const { dispatch, contentIndex, contentData } = this.props
		dispatch(ActionCreators.setVersion({
			id: parseInt(event.target.value),
			index: contentIndex
		}))

		cookie.save('last_bible_version', parseInt(event.target.value), { maxAge: moment().add(1, 'y').toDate(), path: '/' })
		cookie.remove('last_bible_book')

		dispatch(ActionCreators.setField({ index: contentIndex, field: 'human', value: ' ' }))
		dispatch(ActionCreators.setField({ index: contentIndex, field: 'chapter', value: '' }))
		dispatch(ActionCreators.setField({ index: contentIndex, field: 'usfm', value: [''] }))
	}
github quran / quran.com-frontend / src / components / SmartBanner.tsx View on Github external
install() {
    const { daysReminder } = this.props;

    if (!daysReminder) return null;

    let expireDate = new Date();
    expireDate = new Date(
      expireDate.setDate(expireDate.getDate() + daysReminder)
    );

    this.hide();
    cookie.save('smartbanner-installed', 'true', {
      path: '/',
      expires: expireDate,
    });

    return null;
  }
github cdapio / cdap / cdap-ui / app / login / login.js View on Github external
.then((res) => {
        cookie.save('CDAP_Auth_Token', res.access_token, { path: '/' });
        cookie.save('CDAP_Auth_User', this.state.username);
        var queryObj = util.getQueryParams(location.search);
        queryObj.redirectUrl = queryObj.redirectUrl || '/';
        window.location.href = queryObj.redirectUrl;
      });
  }
github mendersoftware / gui / src / js / components / deployments / deployments.js View on Github external
AppActions.getSingleDeployment(id, function(data) {
      if (data.status === "finished") {
        self.setState({onboardDialog: true});
        cookie.save(self.state.user.id+'-onboarded', true);
        cookie.remove(self.state.user.id+'-deploymentID');
      }
    });
  },
github cgarvie / dchan / client / components / App.jsx View on Github external
onLogin(sess) {
    cookie.save('userId', sess.UserId, { path: '/' });
    cookie.save('userSessionKey', sess.SessionKey, { path: '/' });
    this.setState({ userId: sess.UserId, 
                    userSessionKey: sess.SessionKey });
  }
github IamMohaiminul / MERNjs / modules / users / client / services / auth.js View on Github external
export function setToken(token) {
  cookie.save('x-access-token', token, {
    expires: moment().add(1, 'h').toDate(),
  });
}