课程: Building a GraphQL Project with React.js

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Creating a query component

Creating a query component

- [Instructor] It's always a good idea to separate your code so that you have different component for pieces that you need. And I know that this query is going to get pretty complicated. So, I'm going to set it apart as a separate file. So, I'm going to grab this const thing right here and I'm going to create a new document, and I'm going to call this Query.js and then I'm just going to paste it in here. So, let's go ahead and save this. And I also need to, because this is going to be a component now, I need to go ahead and export this as the default item. And I'm going to just export the githubQuery, a little object that I created up there. So, just like before, except we're exporting this now. And then in App.js, let's go back in there, we're going to have to import this. So, we'll do an import here. We'll just call it query, this is the name of it in this component. And then we'll say from the query file that we just…

内容