title: Load initialState dynamically with createSlice in Redux Toolkit
body: <p>Is there a well-known pattern for injecting a payload of dynamic initial state into Redux-Toolkit's initialState object? </p>
  
  <p>That is, I would like to do this - </p>
  
  <pre><code>import initialState from './initialState';
  
  function generateSlice(payload = {}){
    const postsSlice = createSlice({
      name: 'posts',
      initialState: {...initialState, ...payload}, /// inject data here
      reducers: {...}
    })
  }
  </code></pre>
  
  <p>For example, <code>{availableRooms: []}</code> is an empty array, unless injected on init with data <code>{availableRooms: [{...}]}</code></p>
  
  <p>This pattern doesn't work, however, b/c I want to export actions to be dispatch-able, something like this-</p>
  
  <pre><code> const postsSlice = createSlice({
      name: 'posts',
      initialState: {...initialState, ...payload},
      reducers: {...}
    })
  
  export {actionName} from postsSlice.actions;
  
  *****
  import {actionName} from '../mySlice'
  
  ...
  const dispatch = useDispatch();
  dispatch(actionName('exampleVal'));
  ...
  </code></pre>
  
  <p>I am constrained by the <code>airbnb</code> linting rules, so I can't export on let - </p>
  
  <pre><code>let actions; ///Bad
  function generateSlice(payload){
    const postsSlice = createSlice({
      name: 'posts',
      initialState: {...initialState, ...payload},
      reducers: {...}
    })
    actions = postsSlict.actions
  }
  
  export actions;
  </code></pre>
  
  <p>The functionality that I am after is a bit easier without using <code>createSlice</code>. The reason for my question is that I have seen in multiple places that <code>createSlice</code> is recommended over <code>createAction</code> + <code>createReducer</code>, but I don't see any simple way to introduce the dynamic data that I am looking for.</p>
  
  <p>I don't know anything about <code>redux-orm</code> but I think the functionality that I am after is similar to <a href="https://stackoverflow.com/questions/59619753/rewrite-redux-orm-reducer-with-redux-toolkit">this SO question</a></p>