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

Categories

Let's say I have FieldUpdate and FieldUpdate.Radio component

src > components > fieldUpdate > index.tsx, radio.tsx

// index.tsx
import React from 'React';
import Radio from './radio';

const FieldUpdate = (props) => (
  .
  .
  .
);

FieldUpdate.Radio = Radio;
export default FieldUpdate;

If I want to use the FieldUpdate component in Radio component, is it possible? I haven't really go through it yet but when I tried, there was no cyclic import warning. Is it not a best practice? What should I do if I need the FieldUpdate inside Radio? Thanks

question from:https://stackoverflow.com/questions/65938951/dot-notation-for-react-components

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

1 Answer

It is working in this example, but I dont think it is Clean Coding

import React from "react";

const App = () => {
  return (
    <div>
      <Radio />
    </div>
  );
};

export default App;

const Radio = (props) => (
  <div>
    This is Radio
    <FieldUpdate />
  </div>
);

const FieldUpdate = (props) => <div>This is FieldUpdate</div>;

FieldUpdate.Radio = Radio;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...