Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
148 views
in Technique[技术] by (71.8m points)

reactjs - Dynamically modifying React component structure

Let's say I have the following component, defined in Example.tsx module:

export const Example = () => {
  return (
    <Foo bar={true}>
      <div>some div</div>
    </Foo>
   
  )
};

I would like to dynamically modify it from the module I will be using it, so that subcomponents get changed, for example:

export const Example = () => {
  return (
    <Foo bar={true}>
      <p>changed div to p</p>
    </Foo>
   
  )
};

I know exactly that this is what I want to do. I know about props and children - let's assume I cannot use any of these in my case.

question from:https://stackoverflow.com/questions/65546074/dynamically-modifying-react-component-structure

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...