question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected behaviour on import with dynamicTyping

See original GitHub issue

Sorry to disturb you again, but I’ve found this:

If you change your example posts.js to:

const ListActions = (props) => {
  const {
    className,
    basePath,
    total,
    resource,
    currentSort,
    filterValues,
    exporter,
  } = props;
  const config = {
    logging: true,
    validateRow: async (row) => {
      if (row.id) {
        // throw new Error("AAAA");
      }
    },
  };
  return (
    <TopToolbar className={className}>
      <CreateButton basePath={basePath} />
      <ExportButton
        disabled={total === 0}
        resource={resource}
        sort={currentSort}
        filter={filterValues}
        exporter={exporter}
      />
      <ImportButton {...props} {...config} parseConfig={{dynamicTyping: true}}/>
    </TopToolbar>
  );
};

i.e. delete postCommitCallback and add this parseConfig, when you import data with conflicting ids, it will not show the dialog but quit directly. Is it an expected behaviour? Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
peter-jerry-yecommented, Nov 24, 2020
  • The only problem I can see is which ID should be sent to the DataProvider?

It seems to me it is best to send whatever the user give you, i.e. the parse result from csv, so that the user can have full control. That being said, in the definition of Identifier is string | number, so you can send string. Just mark it in the README if you always send a string in case they put identifier as number somewhere in code.

  • If id1 = 2 and id2 = '2' these will become equivalent, so should it always pick the ID from the DataProvider?

I do expect the type in the parse result corresponding to the type from the DataProvider, which is both number in your case. If the type is different but the value is the same, I think it could be safe to say it’s just a type issue: there’s hardly anyone uses two types to define a single table column.

0reactions
benwindingcommented, Nov 25, 2020

Hey @peter-jerry-ye, I’ve just merged it in.

Have a test and let me know if there’s any issues.

Also, what dataprovider are you using in your project? just curious

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module Federation Dynamic Import · Issue #11869 - GitHub
If the current behavior is a bug, please provide the steps to reproduce. I have 2 apps : shell : manager, head of...
Read more >
The Unreasonable Effectiveness of Dynamic Typing for ...
I disagree, I warmed to dynamic typing specifically due to the experience of working with 2-3 million lines of C++ code. The problem...
Read more >
Don't dynamically import code in a directory - ITNEXT
The behavior is unexpected. Not all developers may be aware of the import trick, especially since it's usually limited to certain directories, ...
Read more >
ES2020: `import()` – dynamically importing ES modules - 2ality
First, this import declaration can only appear at the top level of a module. That prevents you from importing modules inside an if...
Read more >
What functionality does dynamic typing allow? [closed]
Most of dynamic typing languages have mechanisms to provide a generic behavior that will catch any message that is passed to their interface....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found