Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug in react 18 with children prop #131

Open
wants to merge 1 commit into
base: 27-react-typescript
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions code/16-finished/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.DS_Store
.vscode
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
4 changes: 3 additions & 1 deletion code/16-finished/src/store/todos-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export const TodosContext = React.createContext<TodosContextObj>({
removeTodo: (id: string) => {},
});

const TodosContextProvider: React.FC = (props) => {
// In React 18.x you have to include the children prop yourself, I wrote solution below

const TodosContextProvider: React.FC<{ children: JSX.Element | JSX.Element[] }> = (props) => {
const [todos, setTodos] = useState<Todo[]>([]);

const addTodoHandler = (todoText: string) => {
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.