gabceb / redux-persist-transform-expire

Add expiration to your persisted store
MIT License
64 stars 19 forks source link

A little help #9

Closed hcyildirim closed 6 years ago

hcyildirim commented 7 years ago

i have redux-persist setup in my index.ios.js and its working but my data coming from db so i dont want to persist this data for lifetime. i need your library :) But i could'nt figure it out how this library works so can someone help me? here is my redux-persist code:

constructor(props) {
    super(props);

    this.state = {
      store: null,
      rehydrated: false,
    };
  }

  componentWillMount() {
    const expireTransform = createExpirationTransform({
      expireKey: 'customExpiresAt',
      defaultState: {},
    });

    this.setState({ store: configureStore() }, () => {
      persistStore(this.state.store, { transforms: [expireTransform], storage: AsyncStorage, blacklist: ['token'] }, () => {
        this.setState({ rehydrated: true });
      });
    });
  }

  render() {
    if (!this.state.rehydrated) return <Text>Loading...</Text>;
    return (
      <Provider store={this.state.store}>
        <App />
      </Provider>
    );
  }