SolidJSS
SolidJSโ€ข3y agoโ€ข
26 replies
Bravi

How to use <Show> in ssr?

Hi everyone. I have this simple code:

export default function Home() {
  const [error, setShowError] = createSignal(false);
  const [_, { Form }] = createRouteAction(async (formData: FormData) => {
    const username = formData.get('username');

    if (username !== 'admin') {
      setShowError(true);
    }
  });

  return (
    <div>
      <Form>
        <label>Username</label>
        <input type="text" name="username" />
      </Form>

      <Show when={error()} keyed>
        oops, you failed
      </Show>
    </div>
  );
}

Is it possible to somehow hide Show part from the downloaded js files? What I mean is, if I land on this page and have a look at the network tab, I can see that string inside one of the JS files.
Was this page helpful?