Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected cached result #85

Closed
himself65 opened this issue Jun 26, 2023 · 5 comments · Fixed by #124
Closed

unexpected cached result #85

himself65 opened this issue Jun 26, 2023 · 5 comments · Fixed by #124

Comments

@himself65
Copy link
Contributor

himself65 commented Jun 26, 2023

export default defineRouter(
  async id => {
    switch (id) {
      case 'index': {
        const { default: AppCreator } = await import('./src/app.js');
        return AppCreator({
          name: 'this is index'
        });
      }
      case 'about': {
        const { default: AppCreator } = await import('./src/app.js');
        return AppCreator({
          name: 'this is about'
        });
      }
      default:
        return null;
    }
  },
  async () => {
    return ['index', 'about'];
  }
);
const App = ({ name = "Anonymous" }) => () => {
  return (
    <div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
      <h1>Hello {name}!!</h1>
      <h3>This is a server component.</h3>
    </div>
  );
};

export default App;

image

image

@himself65 himself65 changed the title unexpected cached value unexpected cached result Jun 26, 2023
@dai-shi
Copy link
Owner

dai-shi commented Jun 26, 2023

Hmm? I don't know how it's happening...
I can investigate it later. A full reproduction might be helpful.

@himself65
Copy link
Contributor Author

@dai-shi
Copy link
Owner

dai-shi commented Jun 26, 2023

Thanks! I know what's happening. It's not about caching.
Currently, waku/router supports nested routes in a unique way. It determines if it's a leaf route by the existence of children. (We may revisit it later as well as how to support nested routes from the ground.)

So, for now, you need to define your App component like the following:

const App = ({ name = "Anonymous" }) => ({ children }) => {
  if (children) return children;
  return (
    <div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
      <h1>Hello {name}!!</h1>
      <h3>This is a server component.</h3>
    </div>
  );
};

export default App;

@dai-shi dai-shi mentioned this issue Aug 1, 2023
83 tasks
@dai-shi
Copy link
Owner

dai-shi commented Sep 10, 2023

#124 will improve about caching (= no cache).
#85 (comment) approach is still valid and unchanged.
#124 will introduce a new api in entries.tsx, so it should be less confusing.

@dai-shi
Copy link
Owner

dai-shi commented Sep 11, 2023

As I wasn't comfortable with caching, I made another change in #124.
Now, it has layout.tsx and page.tsx convention. So, this issue will officially be solved.
We will no longer need #85 (comment) workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants