Skip to content

Add a default mapArgsToProps for react-router-config #2

@NickCis

Description

@NickCis
const mapArgsToProps = (branch, extra) => {
  let { match } = branch || {};

  // On SSR params have to be fixed: https://github.com/ReactTraining/react-router/issues/5296
  if (match && match.params) {
    match = {
      ...branch.match,
      params: Object.keys(branch.match.params).reduce((acc, k) => {
        acc[decodeURIComponent(k)] = decodeURIComponent(branch.match.params[k]);
        return acc;
      }, {}),
    };
  }

  return {
    match,
  };
};

export default mapArgsToProps;

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions