skip to Main Content

Is everything in the following visible / manipulatable by the client – or is just the jsx after the return statement?

const Page: React.FC<Props> = (props) => {
  const {x, y, z} = props;
  if(x) {
    return <>{y}</>
  } else {
    return <>{z}</>
  }
}

Would a client be able to access the value of x y & z in the above regardless of what x is? I’m asking in the context of trying to understand how to conditionally serve parts of a page based on a user role.

2

Answers


  1. As far as I understood your question, the Client (browser) displays the JSX which is being returned by the return statement. Whatever logic that you need to manipulate can be written before the jsx.

    Hope this helps

    Login or Signup to reply.
  2. If by client your mean the browser, it will have access to all of the compiled javascript, although it can be hard to read if minified. Any value declared or returned from a server is also available. In React JSX results in HTML, that is eventually rendered in the DOM.

    Anything sensitive should be stored server-side. Given enough time anything in a client can be reverse engineered.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search